Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How can i pass the OBJECT TYPE as argument in function

791525Jan 19 2011 — edited Jan 19 2011
Hi folks,
I was create one function that function return type is OBJECT, and i pass that OBJECT as argument to another function. while i pass the OBJECT as argument from one function to another function, that OBJECT argument goes null value to another function.

How can i overcome this problem. can please give the solution for this issue.


Here i pasted my coding..

From the below function i pass the OBJECT as argument to another function
CREATE OR REPLACE FUNCTION F_Ln_Getodperd
RETURN str_batch
IS
v_n_cnt NUMBER;
lstr_od str_batch := NEW str_batch(NULL,NULL) ;

BEGIN
	SELECT SYSDATE
	INTO lstr_od.d 
	FROM dual;
	
	SELECT 1 
	INTO lstr_od.n 
	FROM dual;
	
	SELECT F_Insert1(lstr_od) INTO v_n_cnt FROM dual; *Here i pass the OBJECT as argument to  F_Insert1 function *
	
	IF (v_n_cnt =0) THEN
	   dbms_output.put_line('Insertion Failed!');
	END IF;	
	
	--INSERT INTO A(N, D) VALUES(lstr_od.n,lstr_od.d);
	RETURN lstr_od;
END;
/
        
while i pass the OBJECT argument to another funtion it was go null
CREATE OR REPLACE FUNCTION F_Insert
(Arg str_batch)RETURN NUMBER
IS
  st str_batch;
BEGIN 

  IF st IS NOT NULL THEN
	  INSERT INTO A(N, D) VALUES(st.n,st.d);
  ELSE
	dbms_output.put_line('Object is empty');
	ROLLBACK;
	RETURN 0;
  END IF;		
   
  COMMIT; 	  
  RETURN 1;
END;
/
        
CREATE OR REPLACE
TYPE str_batch IS OBJECT 
( 
   d DATE , 
   n NUMBER 
)
/
    
Thanks in advance,
Arun

Edited by: Arun on Jan 18, 2011 10:38 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 16 2011
Added on Jan 19 2011
7 comments
1,112 views