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!

for loop dynamic sql

705271Jul 3 2010 — edited Dec 21 2012
how could i write for loop using dynamic sql in package and
i don't want to use the fetch , please help ,thanks

procedure test
(in_table_name varchar2, in_com_name varchar2, in_date date) AS

l_sql varchar(2000);

begin
l_sql := 'SELECT staff_id '
|| 'from ' || in_table_name
|| 'where company_name = ' || in_cop_name
|| 'and reg_date = '|| in_date ;


for cur in (l_sql) loop

dbms_output.put_line('staff id = '||cur.staff_id);
end loop;
end;

Edited by: user11156736 on 2010/7/2 下午 11:00

Edited by: user11156736 on 2010/7/2 下午 11:01
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 18 2013
Added on Jul 3 2010
9 comments
25,860 views