ITPub博客

首页 > 应用开发 > IT综合 > cursor参数

cursor参数

原创 IT综合 作者:maojinyu 时间:2011-08-23 16:37:46 0 删除 编辑
declare
cursor t is select * from mao.tabs where rownum<10;
cursor c(t_name tabs.table_name%type) is select * from mao.cols where cols.table_name=t_name;
t_r tabs%rowtype;
c_r cols%rowtype;
begin
for t in (select * from mao.tabs where rownum<10) loop
dbms_output.put_line(t.owner||' '||t.table_name||': ');
dbms_output.put_line('-------');
for c in(select * from mao.cols where table_name=t.table_name) loop
dbms_output.put_line(c.column_name);
end loop;
dbms_output.put_line('-------');
end loop;
end;[@more@]declare
cursor t is select * from mao.tabs where rownum<10;
cursor c(t_name tabs.table_name%type) is select * from mao.cols where cols.table_name=t_name;
t_r tabs%rowtype;
c_r cols%rowtype;
begin
open t;
loop
fetch t into t_r;
exit when t%notfound;
dbms_output.put_line(t_r.table_name||':');
dbms_output.put_line('-----');
open c(t_r.table_name);
loop
fetch c into c_r;
exit when c%notfound;
dbms_output.put_line('Colum name:'||c_r.column_name);
end loop;
close c;
dbms_output.put_line('-----');
end loop;
close t;
end;

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9907339/viewspace-1054230/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2012-05-09

  • 博文量
    178
  • 访问量
    376687