Oracle: Return multiple values in a function

前端 未结 3 907
长情又很酷
长情又很酷 2021-02-10 17:06

I\'m trying to return a multiple values in a %rowtype from a function using two table(employees and departments), but it not working for me.

create or replace fu         


        
3条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-10 17:56

    CREATE OR replace FUNCTION Funmultiple(deptno_in IN NUMBER)
      RETURN NUMBER AS v_refcursur SYS_REFCURSOR;
      BEGIN
        OPEN v_refcursor FOR
        SELECT *
        FROM   emp
        WHERE  deptno = deptno_in;
        
        retun v_refcursor;
      END;
    

    To call it, use:

    variable x number
    exec :x := FunMultiple(10);
    print x 
    

提交回复
热议问题