How to fetch the rows by dynamicaly passing table name through cursor

Showing Answers 1 - 9 of 9 Answers

We have to use stored procedure and parameterized cursor.

1) Write a stored procedure which takes table name as IN parameter.

2) Pass that table name as a parameter to cursor(using PARAMETERIZE CURSOR)

3) Fetch the rows u need

4) execute that procedure.

  Was this answer useful?  Yes

Kashif

  • Apr 19th, 2006
 

Hi praveen,

   I don't think table name can be passed as parameter to cursor. In this case we need to use ref-cursor .Am I right, Do let me know.

  

  Was this answer useful?  Yes

Divesh Bansal

  • Apr 23rd, 2006
 

Hi Table name cant be passed as paramter in cursor. Se have to go with the ref curson where we will write the dynamic sql Please mail me for furhet discuss Thanks Divesh

  Was this answer useful?  Yes

CHINMAY

  • Jun 27th, 2007
 


Yes,
You are right we can only pass the value for where clause in paramterised cursor

  Was this answer useful?  Yes

lieni

  • Jul 30th, 2007
 

Yes you can pass the whole select statement of the cursor dynamicaly, see ref_cursors.

There is also a system package sys.dbms_sql which allows everything to make dynamically.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions