请各位高手帮忙急用!

解决方案 »

  1.   

    LZ是要这种的吗:
    declare
    v1 varchar2(200);
    begin
    for c1 in (select语句) loop
    v1:=c1.字段名;
    end loop;
    end;
    还是说不知道游标里面有哪些列,要遍历游标列呢?
      

  2.   

    给个例子,游标遍历select table_name from user_tablesset serveroutput on;declare type sp_test1_cursor is ref cursor;
            test1_cursor sp_test1_cursor;
            v_name user_tables.TABLE_NAME%type;
            v_count number;
            strsql varchar2(100);
    begin
      open test1_cursor for select table_name from user_tables;
      loop
        fetch test1_cursor into v_name;
        if v_name is not null then
          strsql:='select count(*) from ' || v_name;
          execute immediate strsql into v_count;
         end if;
         exit when test1_cursor%notfound;
         dbms_output.put_line(v_name||'          '||v_count);
      end loop;
      close test1_cursor;
    end;
      

  3.   

    declare 
      cursor mysor is select * from emp;
    begin
       for i in mysor
         loop
            dbms_output.put_line(i.ename||e.deptno);
         end loop; 
    end;
    这样就可以获得全部信息
      

  4.   

    set serveroutput on;declare type sp_test1_cursor is ref cursor;
            test1_cursor sp_test1_cursor;
            v_name user_tables.TABLE_NAME%type;
            v_count number;
            strsql varchar2(100);
    begin
      open test1_cursor for select table_name from user_tables;
      loop
        fetch test1_cursor into v_name;
        if v_name is not null then
          strsql:='select count(*) from ' || v_name;
          execute immediate strsql into v_count;
         end if;
         exit when test1_cursor%notfound;
         dbms_output.put_line(v_name||'          '||v_count);
      end loop;
      close test1_cursor;
    end;