If you declare a variable inside the procedure they you can refer the value or assign the value only from that stored procedure, its called local variable.
If you want to refer a same variable from different procedures or functions or packages then what we should do? We should declare a variable in a package spec so that we can refer that variable from any where we want in the Pl/SQL block.
Now we will take an example of a package spec.
CREATE OR REPLACE PACKAGE pack_glb_example IS
--We declare a cursor
in package, so we can refer this cursor from any procedure or function.
--If you declare
this cursor inside the procedure then you can refer this cursor with in
the stored procedure.
--Its global cursor
cursor c_check_cust_no ( v_cust_no number ) is
select 1 from customer where customer_no = v_cust_no
)
--Global variable
var_cust_hold number;
procedure delete_customer( cust_no number );
function get_customer_name ( cust_no number) return varchar2;
END pack_glb_example;