[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:

package session value not set

Hi,
I am trying to get the value from varaible from session but some how I get null value not really sure the reason.
Could use help.

create or replace
PACKAGE CONVPKG AS

TYPE MY_TYPE IS RECORD (
    column1  NVARCHAR2(1),
    coulmn2    VARCHAR2(1)
  );


PROCEDURE loadP;

FUNCTION getP RETURN Varchar2;

END CONVPKG;


create or replace
PACKAGE BODY DELCCONVPKG AS

my_cached boolean := false;
my MY_TYPE := null;



PROCEDURE loadP
AS
OutParam MY_TYPE;
BEGIN

IF my_cached  THEN
OutParam.column1 := 'b';
outparam.column1 := 'B';
my := outparam;


      END IF;
END;

FUNCTION getP RETURN VARCHAR2
AS
BEGIN
DBMS_OUTPUT.PUT_LINE('c');
RETURN my.column1;
END;

BEGIN
loadP;
0
dojjol
Asked:
dojjol
2 Solutions
 
flow01Commented:
The specifacation has another name as the body.
And my_cached is false so outparam is not filled.

change loadp
IF not my_cached THEN
don't forget to set my_cached TRUE after filling my.

Your coding example ends with
loadP;
i cant see the rest of the package body
0
 
slightwv (䄆 Netminder) Commented:
From your previous question, I'm still confused.

You set the value of my_cache to false therefore the if statement will never be entered.

Below is some code that returns the 'B' and tested using sqlplus.

I also fixed the typos.
create or replace
PACKAGE CONVPKG AS 

TYPE MY_TYPE IS RECORD (
    column1  NVARCHAR2(1),
    coulmn2    VARCHAR2(1)
  );


PROCEDURE loadP;

FUNCTION getP RETURN Varchar2;

END CONVPKG;
/

show errors


create or replace
PACKAGE BODY CONVPKG AS

	my_cached boolean := true;
	my MY_TYPE := null;


	PROCEDURE loadP
	AS
	OutParam MY_TYPE;
	BEGIN

		IF my_cached  THEN
			OutParam.column1 := 'b';
			outparam.column1 := 'B';
			my := outparam;
      END IF; 
	END;

	FUNCTION getP RETURN VARCHAR2
	AS
	BEGIN
		DBMS_OUTPUT.PUT_LINE('c');
		RETURN my.column1;
	END;


end;
/

show errors

declare
	retval char(1);
begin
	convpkg.loadp;
	
	DBMS_OUTPUT.PUT_LINE('Got: ' || convpkg.getp);
end;
/

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now