Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to pass a dyanmic table name to

Status
Not open for further replies.

Darshu

Programmer
Jul 25, 2006
21
0
0
US
how to pass a dyanmic table name to a select statement for declaring a cursor in stored procedure.can any one help
.please if possible give a example
thanks darshu
 
here is an example (slightly modifed) from the Oracle Applications Developer's Guide:

DECLARE
TYPE EmpCurTyp IS REF CURSOR;
cur EmpCurTyp;
stmt_str VARCHAR2(200);
name VARCHAR2(20);
salary NUMBER;
table VARCHAR2 (30);
BEGIN
table := 'emp';
stmt_str := 'SELECT ename, sal FROM ' || table ||
' WHERE job = :1';
OPEN cur FOR stmt_str USING 'SALESMAN';

LOOP
FETCH cur INTO name, salary;
EXIT WHEN cur%NOTFOUND;
-- <process data>
END LOOP;
CLOSE cur;
END;
/
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top