Hi. I have created a function (Retrieve_SerialNo) which returns a variable, which I use throughout my package. I would like to assign this variable as a global variable to be used by all functions and procedures in the package. Can someone help me in the declaration of this variable as a global variable? Also, is it necessary for me to initialize this variable whenever the package executes. If yes, how would I do this?
CREATE OR REPLACE PACKAGE BODY Supply_Item_Interface AS
FUNCTION Retrieve_SerialNo RETURN VARCHAR2 IS
v_serial_no VARCHAR2(20);
CURSOR Serial_Code IS
SELECT S.Serial_Code
FROM Spare_Parts s, Orders r
WHERE s.serial_code = r.serial_code;
BEGIN
OPEN Serial_Code;
LOOP
FETCH Serial_Code
INTO v_serial_no;
EXIT WHEN Serial_Code%NOTFOUND;
v_serial_no := v_serial_no;
END LOOP;
CLOSE Serial_Code;
RETURN v_serial_no;
EXCEPTION
WHEN OTHERS THEN
RETURN NULL;
END;