GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Oracle  >  SQL
Go To First  |  Previous Question  |  Next Question 
 SQL  |  Question 145 of 171    Print  
Can you use a reference cursor as an input parameter in a procedure with out declaring it explicitly?

  
Total Answers and Comments: 3 Last Update: May 18, 2008     Asked by: Ashwin 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
January 19, 2008 10:42:52   #1  
mohdfarezpink Member Since: January 2008   Contribution: 4    

RE: Can you use a reference cursor as an input parameter in a procedure with out declaring it explicitly?

No because an Explicit cursor is the only one we are going to create that only we can able to keep as a parameter Implicit cursor is created by the oracle server only so we can't access it


 
Is this answer useful? Yes | No
May 16, 2008 05:27:29   #2  
krishnaindia2007 Member Since: September 2007   Contribution: 854    

RE: Can you use a reference cursor as an input parameter in a procedure with out declaring it explicitly?
Question it self is wrong.

In cursors there are two types.
1.Implicit cursors
2. Explicit cursors
Explicit cursors can be defined as dynamic (Reference ) or static.
Only reference cursors can be passed as parameter - static cursor can't.

 
Is this answer useful? Yes | No
May 18, 2008 00:56:01   #3  
krishnaindia2007 Member Since: September 2007   Contribution: 854    

RE: Can you use a reference cursor as an input parameter in a procedure with out declaring it explicitly?
Oh sorry.

You can not declare . Here is the example
PROCEDURE test_ref (emp_cur IN my_refcursor) IS
emp_rec emp ROWTYPE;
BEGIN
LOOP
FETCH emp_cur INTO emp_rec;
EXIT WHEN emp_cur NOTFOUND;
dbms_output.put_line(emp_rec.ename ||' is a ' || emp_rec.job);
END LOOP;
END;

It will throw error
PLS-00201: identifier 'MY_REFCURSOR' must be declared

But you can pass it as sys_refcursor without getting any error.

CREATE OR REPLACE PROCEDURE test_ref (emp_cur IN sys_refcursor) IS
emp_rec emp ROWTYPE;
BEGIN
LOOP
FETCH emp_cur INTO emp_rec;
EXIT WHEN emp_cur NOTFOUND;
dbms_output.put_line(emp_rec.ename ||' is a ' || emp_rec.job);
END LOOP;
END;



 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape