用遊標可以,定義一個%ROWTYPE類型的

解决方案 »

  1.   

    1.
    CREATE OR REPLACE PROCEDURE prc_one IS
    TYPE refCursor IS REF CURSOR;
    cur_test refcursor;
    rowType_tab scott.emp%ROWTYPE;
    BEGIN
      OPEN cur_test FOR SELECT * FROM scott.emp;
      LOOP
        FETCH cur_test INTO rowType_tab;
        EXIT WHEN cur_test%NOTFOUND;
        dbms_output.put_line(rowType_tab.Empno || '...');  -- 在这里写字段名
      END LOOP;
      CLOSE cur_test;
    END prc_one;
      

  2.   

    2. 用上面那个方法.open cur_test for select * from emp where...   -- 在这里写条件(部门)
    输出...
    close cur_test;
    open cur_test for select * from emp where...   -- 在这里写条件(部门)
    输出...
    close cur_test;...