Can an SQL procedure return a table?

后端 未结 3 773
悲哀的现实
悲哀的现实 2020-12-31 16:33

Can an Oracle SQL procedure return a table? I\'m currently using a dbms_output to print out the outputs of two cursors which are in a loop, although this would

3条回答
  •  温柔的废话
    2020-12-31 17:17

    This may also help:

    DECLARE
      TYPE t_emptbl IS TABLE OF scott.emp%rowtype;
      v_emptbl t_emptbl; 
      ret_val  t_emptbl; 
      --
      Function getEmployeeList Return t_emptbl 
      IS
      BEGIN
        SELECT * bulk collect INTO v_emptbl FROM scott.emp;
        -- Print nested table of records:
        FOR i IN 1 .. v_emptbl.COUNT LOOP
          DBMS_OUTPUT.PUT_LINE (v_emptbl(i).empno);
        END LOOP;
        RETURN v_emptbl;
      END;
      --
      BEGIN
        ret_val:= getEmployeeList;
      END;
      /
    

提交回复
热议问题