select *** from user_tables能找到用户下的表。
select *** from user_tab_cols能找到某表的字段。
做成两个游标套在一起,可以吗?记得及时给每个回贴人的散分!

解决方案 »

  1.   

    create or replace procedure curtest
     is
       at_str varchar(2000);
       str_tname varchar(2000);
       acl_str varchar(2000);
       cl_tname varchar(2000);
       type t_cur is ref cursor;
       at_cur t_cur;
       acl_cur t_cur;
    begin
       at_str:='select TABLE_NAME from user_tables';
       open at_cur for at_str;
           loop
               fetch at_cur into str_tname;
               acl_str:='select COLUMN_NAME from user_tab_cols where TABLE_NAME ='''||str_tname||'''';
               open acl_cur for acl_str;
                   loop
                       fetch acl_cur into cl_tname;
                       DBMS_output.Put_Line(cl_tname);               
                   exit when acl_cur%notfound;
                   end loop;
               close acl_cur;
           exit when at_cur%notfound;
           end loop;
       close at_cur;
    end curtest;你自己修改一下,good luck
      

  2.   

    open at_cur (第12行开头)是什么意思?
      

  3.   


     open at_cur :就是打开一个ref cursor,你可以把它理解成dynamic cursor(动态游标)