Plsql use a function which returns a ref cursor

Hi
I've been using an function which returns a ref cursor. I've been returning this into a java resultset. Fine!
Now i'm in plsql and want to use the same function. I'm not sure how to get this resultset in plsql.

It's not very practical to use a refcursor like you want to, but here you go
create or replace function test_ref
return sys_refcursor
is
v_rc sys_refcursor;
begin
open v_rc for select emp_name  from emp ;
return v_rc;
end;
declare
v_rc sys_refcursor;
v_emp_name emp.emp_name%type;
begin
v_rc :=  test_ref ;
loop
    fetch v_rc into v_emp_name ;
    exit when v_rc%notfound ;
    dbms_output.put_line('Employee Name: '||v_emp_name );
end loop;
end;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • Function call returned in ref cursor

    We have a ref cursor that calls a function in a package. When ODP.NET reads the cursor, it can't see what the function is returning. OO4O works fine, and if I take the sql that populates the ref cursor and put it into a temporary table, then select from that temporary table to return the ref cursor to ODP, it works fine. Anyone else seen this issue? Any help would be appreciated. Thanks.
    Eric Schrauth
    [email protected]

    Did you set the parameter direction to be ParameterDirection.Input when you created the parameter? Post your code.

  • Oracle Function returns a Ref Cursor to a ResultSet object - Performance

    My program calls an Oracle PL/SQL function which returns a ref cursor to a ResultSet object. I know that the function runs to completion relatively quickly when i run it in an anonymous block but when the call is made through my Java application the resultset takes about 30 mins to return. Below is a snippet of my code:
    currentConnection = ConnectionManager.getInstance().getConnection();
    reportStmt = currentConnection.prepareCall("BEGIN ? := ENVISION.PKG_WMS_TO_AP.F_REPORT_CI_SC_HOLDING(?,?); END;"); reportStmt.registerOutParameter(1, OracleTypes.CURSOR);
    reportStmt.setString(2, invoice.getCrewHQ());
    reportStmt.setDate(3, invoice.getWrCompletionDate());
    reportStmt.execute();
    reportRS = ((OracleCallableStatement) reportStmt).getCursor(1);
    Through a debugger I see that the second last statement (reportStmt.execute()) runs quickly. It is only when I step into the last statement that the debugger takes up to 30 minutes.
    Any thoughts?

    Flynn,
    The Internet is a dynamic place. After nearly two and a half years, there is a chance that a link will change. This is the new URL for the relevant Web page:
    http://asktom.oracle.com/~tkyte/ResultSets/
    Good Luck,
    Avi.

  • Function which returns multiple values that can then be used in an SQL Sele

    I'd like to create a function which returns multiple values that can then be used in an SQL Select statement's IN( ) clause
    Currently, the select statement is like (well, this is a very simplified version):
    select application, clientid
    from tbl_apps, tbl_status
    where tbl_apps.statusid = tbl_status.statusid
    and tbl_status.approved > 0;
    I'd like to pull the checking of the tbl_status into a PL/SQL function so my select would look something like :
    select application, clientid
    from tbl_apps
    where tbl_apps.statusid in (myfunction);
    So my function would be running this sql:
    select statusid from tbl_status where approved > 0;
    ... will return values 1, 5, 15, 32 (and more)
    ... but I haven't been able to figure out how to return the results so they can be used in SQL.
    Thanks for any help you can give me!!
    Trisha Gorr

    Perhaps take a look at pipelined functions:
    Single column example:
    SQL> CREATE OR REPLACE TYPE split_tbl IS TABLE OF VARCHAR2(32767);
      2  /
    Type created.
    SQL> CREATE OR REPLACE FUNCTION split (p_list VARCHAR2, p_delim VARCHAR2:=' ') RETURN SPLIT_TBL PIPELINED IS
      2      l_idx    PLS_INTEGER;
      3      l_list   VARCHAR2(32767) := p_list;
      4      l_value  VARCHAR2(32767);
      5    BEGIN
      6      LOOP
      7        l_idx := INSTR(l_list, p_delim);
      8        IF l_idx > 0 THEN
      9          PIPE ROW(SUBSTR(l_list, 1, l_idx-1));
    10          l_list := SUBSTR(l_list, l_idx+LENGTH(p_delim));
    11        ELSE
    12          PIPE ROW(l_list);
    13          EXIT;
    14        END IF;
    15      END LOOP;
    16      RETURN;
    17    END SPLIT;
    18  /
    Function created.
    SQL> SELECT column_value
      2  FROM TABLE(split('FRED,JIM,BOB,TED,MARK',','));
    COLUMN_VALUE
    FRED
    JIM
    BOB
    TED
    MARK
    SQL> create table mytable (val VARCHAR2(20));
    Table created.
    SQL> insert into mytable
      2  select column_value
      3  from TABLE(split('FRED,JIM,BOB,TED,MARK',','));
    5 rows created.
    SQL> select * from mytable;
    VAL
    FRED
    JIM
    BOB
    TED
    MARK
    SQL>Multiple column example:
    SQL> CREATE OR REPLACE TYPE myrec AS OBJECT
      2  ( col1   VARCHAR2(10),
      3    col2   VARCHAR2(10)
      4  )
      5  /
    Type created.
    SQL>
    SQL> CREATE OR REPLACE TYPE myrectable AS TABLE OF myrec
      2  /
    Type created.
    SQL>
    SQL> CREATE OR REPLACE FUNCTION pipedata(p_str IN VARCHAR2) RETURN myrectable PIPELINED IS
      2    v_str VARCHAR2(4000) := REPLACE(REPLACE(p_str, '('),')');
      3    v_obj myrec := myrec(NULL,NULL);
      4  BEGIN
      5    LOOP
      6      EXIT WHEN v_str IS NULL;
      7      v_obj.col1 := SUBSTR(v_str,1,INSTR(v_str,',')-1);
      8      v_str := SUBSTR(v_str,INSTR(v_str,',')+1);
      9      IF INSTR(v_str,',')>0 THEN
    10        v_obj.col2 := SUBSTR(v_str,1,INSTR(v_str,',')-1);
    11        v_str := SUBSTR(v_str,INSTR(v_str,',')+1);
    12      ELSE
    13        v_obj.col2 := v_str;
    14        v_str := NULL;
    15      END IF;
    16      PIPE ROW (v_obj);
    17    END LOOP;
    18    RETURN;
    19  END;
    20  /
    Function created.
    SQL>
    SQL> create table mytab (col1 varchar2(10), col2 varchar2(10));
    Table created.
    SQL>
    SQL> insert into mytab (col1, col2) select col1, col2 from table(pipedata('(1,2),(2,3),(4,5)'));
    3 rows created.
    SQL>
    SQL> select * from mytab;
    COL1       COL2
    1          2
    2          3
    4          5

  • Error while calling the function which returns SQL Query!!!

    Hi,
    I have a Function which returns SQL query. I am calling this function in my APEX report region source.
    The query is dynamic SQL and its size varies based on the dynamic "where clause" condition.
    But I am not able to execute this function.It gives me the following error in APEX region source.
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    Even in SQL* Plus or SQL developer also same error .
    The length of my query is more than 4000. I tried changing the variable size which holds my query in the function.
    Earlier it was
    l_query varchar2(4000)
    Now I changed to
    l_query varchar2(32767).
    Still it is throwing the same error.
    Can anybody help me to resolve this.???
    Thanks
    Alaka

    Hi Varad,
    I am already using 32k of varchar2. Then also it is not working.
    It is giving the same error. I think there is something to do with buffer size.
    My query size is not more than 4200. Even if i give 32k of varchar2 also buffer is able to hold only 3997 size of the query only.
    Error is
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    Tried CLOB also. It is not working.
    Any other solution for this.
    Thanks
    Alaka

  • Parallel  piplelined function not parallelizing with ref cursor

    RDBMS 11.2.0.3
    I have a function with the following signature
    function to_file (
      p_source     in  sys_refcursor
    , p_file_name  in  varchar2
    , p_directory  in  varchar2 default 'DD_DUMP'
    return dd_dump_ntt
    pipelined
    parallel_enable ( partition p_source by any )
    authid current_user;The function works in parallel when I use a cursor expression like this
    begin
      for rec in ( select *
                   from table(dd_dump.to_file( cursor(select /*+ parallel(i 4) */ c1||chr(9)||c2 from mytable i), 'f.out' ))
      loop
        dbms_output.put_line(rec.file_name || chr(9) || rec.num_records );
      end loop;
    end;
    f.out_162     276234
    f.out_213     280399
    f.out_230     286834
    f.out_70     289549But when I use a refcursor, it does not run in parallel
    declare
      rc sys_refcursor;
    begin
      open rc for 'select /*+ parallel(i 4) */ c1||chr(9)||c2 from mytable i';
      for rec in ( select *
                   from table(dd_dump.to_file( rc, 'f.out' ))
      loop
        dbms_output.put_line(rec.file_name || chr(9) || rec.num_records );
      end loop;
    end;
    f.out_914     1133016Is this an expected behavior or am I doing something wrong? How can I use the function when the client returns the SQL statement as a character string
    Edited by: Sanjeev Chauhan on Mar 9, 2012 11:54 AM

    Sanjeev Chauhan wrote:
    I am not performing any DML in the pipelined function. If you read the note carefuly it shows parallel_enable works only when you use:
    table(table_function(<font color=red>CURSOR</font>(select...)))and not when you use
    table(table_function(<font color=red>ref-cursor-name</font>))SY.

  • How to return a ref cursor from this dbms_sql?

    Hi,
    Can anyone show me how to return a ref cursor from this dbms_sql based procedure? I see 11g has a dbms_sql.to_refcursor(cursor_handle). How can this be done is 10g?
    Thx.
    CREATE OR REPLACE PROCEDURE Sample_Get_t
    p_sample_id sample.sample_id%TYPE,
    p_contract_id sample.contr_id%TYPE
    IS
    cursor_handle INT;
    sql_stmnt varchar2(500);
    rows_processed NUMBER;
    BEGIN
    sql_stmnt :=
    'SELECT
    sample_id,
    contr_id,
    rcpt_id
    FROM
    sample s
    WHERE
    s.contr_id = :1
    and s.sample_id = :2
    ORDER BY
    sample_id';
    cursor_handle := dbms_sql.open_cursor;
    dbms_sql.parse(cursor_handle, sql_stmnt, dbms_sql.native);
    dbms_sql.bind_variable(cursor_handle, ':1', p_contract_id);
    dbms_sql.bind_variable(cursor_handle, ':2', p_sample_id);
    rows_processed := dbms_sql.execute(cursor_handle);
    dbms_sql.close_cursor(cursor_handle);
    END Sample_Get_t;

    In 10 this cannot be done with dbms_sql (to my knowledge). There are a couple of other options.
    1) open the ref cursor for the dynamic statement using bind variables (or SYS_CONTEXT variables, which i prefer since they are much easier to deal with when you are dynamically adding predicates).
    declare
       wRefCursor  SYS_REFCURSOR;
    begin
       open wRefCursor for 'select * from all_objects where owner = :Logged_in_user' using user;
    end;
    /or using the context (the context will bind for you)
    declare
       wRefCursor  SYS_REFCURSOR;
    begin
       open wRefCursor for 'select * from all_objects where owner = SYS_CONTEXT(''CONTEXT_NAME'', ''VARIABLE_NAME'') ';
    end;
    /Be aware that contexts ALWAYS return varchar values, so if you are comparing to a number you should wrap it in TO_NUMBER, a date, TO_DATE and so on....
    2) change the DBMS_SQL to do an insert into a global temporary table and return the ref cursor which select's * from GTT;
    3) upgrade to Oracle 11 :)

  • Procedure to RETURN a REF CURSOR

    Environment:
    OWB10g Client on Windows XP Professional
    Repository - 9.2.0.4 on UNIX (AIX 5.2)
    Target - 9.2.0.4 on UNIX (AIX 5.2)
    Is it possible to create a PROCEDURE in OWB that returns a REF CURSOR?
    It was not one of the TYPEs available when specifying the procedure parameters.
    Is this an enhancement that's coming if it's not possible today?
    Many thanks for all feedback. This is a great interactive discussion forum.
    Gary

    Good afternoon Gary,
    Have you checked whether it's possible to use the table-function?
    Don't know you specific requirements, but according to the explanation ("Table functions extend PL/SQL and are a new option in Oracle9i. This option allows a function to accept, process and return multiple rows.") it at least is capable of returning rowtypes.
    Cheers, Patrick

  • Use function which returns clob in proceudre

    Hello,
    I need some help with a function call i am using.
    I have a SYSMAN function which i like to call in procedure.
    The output from the function is a CLOB.
    Executing the statement in SqlPlus returns 2 lines of data, but written into a procedure returns in an error.
    The procedure looks like this:
         CREATE OR REPLACE PROCEDURE large_val as
         cSql_text          CLOB;
         sSql_stmt           varchar2(200);
         job_id          varchar2(80);
         exec_id          varchar2(80);
         parm          varchar2(50);
         begin
         job_id := '82A11DD897876D29E0400A0A8A1051A7';
         exec_id := '0000000000000000';
         parm := 'large_sql_script';
         sSql_stmt := 'SELECT SYSMAN.MGMT_JOBS.get_large_param(' || ''''||job_id||'''' ||',' ||''''||exec_id||''''||','||''''||parm|| '''' || ') FROM DUAL;';
         dbms_output.put_line(sSql_stmt);
         execute immediate sSql_stmt into cSql_text;
         END large_val;
    The output from dbms_output i am able to run a statement in SqlPlus without error:
         SELECT SYSMAN.MGMT_JOBS.get_large_param('82A11DD897876D29E0400A0A8A1051A7','0000000000000000','large_sql_script') FROM DUAL ;
    and it returns 2 lines.
    Running it as a procecure show's an error i don't understand.
    exec large_val;
    BEGIN large_val; END;
    ERROR at line 1:
    ORA-00911: invalid character
    ORA-06512: at "SCHEMTS.LARGE_VAL", line 23
    ORA-06512: at line 1
    Hope anyone can help me.
    Any help is appreciated.
    Regards,
    Ben

    Kiran wrote:
    you cannot use CLob with select query.Yes you can. At least since 10gR1, but possibly in earlier versions too.
    @OP:
    Why aren't you using bind variables? And why are you using dynamic sql at all?
    You could just do
      cSql_text := SYSMAN.MGMT_JOBS.get_large_param(job_id, exec_id, parm);

  • How to use the function who returns an array?

    how to use getAllT in pls/sql or in java?
    --------------------------------------------------->
    create or replace package honghai as
         type TType is varray(25) of number;
    /*it can be like : type TType is table of number;
         function getCountT return number;
         function getAllT return TType;
    end honghai;
    create or replace package body honghai as
    a number;
    function getCountT return number is
         acount number;
         begin
              select count(*) into acount from testasb.t;
              return acount;
         end getCountT;
         function getAllT
         return TType is
         results TType;
         begin
              select testid into results(25) from testasb.T ;
              return results ;
         end getAllT;
    begin
         a := 2;     
    end honghai;
         

    For the java part, click on the link below:
    http://osi.oracle.com/~tkyte/ResultSets/index.html
    For the pl/sql part specific to your problem, see the code below. Since you did not provide any table structure or sample data, I used some simple data for demonstration purposes:
    SQL> CREATE TABLE t
      2    (testid NUMBER)
      3  /
    Table created.
    SQL> INSERT INTO t
      2  VALUES (1)
      3  /
    1 row created.
    SQL> INSERT INTO t
      2  VALUES (2)
      3  /
    1 row created.
    SQL> CREATE OR REPLACE PACKAGE honghai
      2  AS
      3    TYPE ttype IS REF CURSOR;
      4    FUNCTION getcountt RETURN NUMBER;
      5    FUNCTION getallt RETURN ttype;
      6  END honghai;
      7  /
    Package created.
    SQL> CREATE OR REPLACE PACKAGE BODY honghai
      2  AS
      3    a NUMBER;
      4    FUNCTION getcountt RETURN NUMBER
      5    IS
      6      account nUMBER;
      7    BEGIN
      8      SELECT COUNT (*)
      9      INTO   account
    10      FROM   scott.t;
    11      RETURN account;
    12    END getcountt;
    13    FUNCTION getallt RETURN ttype
    14    IS
    15      results ttype;
    16    BEGIN
    17      OPEN results for 'SELECT testid FROM scott.t';
    18      RETURN results;
    19    END getallt;
    20  BEGIN
    21    a := 2;
    22  END honghai;
    23  /
    Package body created.
    SQL> VARIABLE g_num NUMBER
    SQL> VARIABLE g_ref REFCURSOR
    SQL> EXEC :g_num := honghai.getcountt
    PL/SQL procedure successfully completed.
    SQL> EXEC :g_ref := honghai.getallt
    PL/SQL procedure successfully completed.
    SQL> PRINT g_num
         G_NUM
             2
    SQL> PRINT g_ref
        TESTID
             1
             2

  • How to use stored procedure which returns result set in OBIEE

    Hi,
    I hav one stored procedure (one parameter) which returns a result set. Can we use this stored procedure in OBIEE? If so, how we hav to use.
    I know we hav the Evaluate function but not sure whether I can use for my SP which returns result set. Is there any other way where I can use my SP?
    Pls help me in solving this.
    Thanks

    Hi Radha,
    If you want to cache the results in the Oracle BI Server, you should check that option. When you run a query the Oracle BI Server will get its results from the cache, based on the persistence time you define. If the cache is expired, the Oracle BI Server will go to the database to get the results.
    If you want to use caching, you should enable caching in the nqsconfig.ini file.
    Cheers,
    Daan Bakboord

  • Unit test, how to test a function which returns a PL/SQL table.

    I've got the following type definition:
    create or replace type method_tbl as table of varchar2(255);
    /I've got the following function
    function abc(p_param1 in varchar2) return method_tbl;When I create a unit test for this I am not able to specify what the table should contain on return of the function, all I can see is an empty table. Which is off course one of the unit tests. But I also want to test where the table that is returned contains a number of rows.
    Is there something that I'm missing?
    Typically the function is called like this:
    select * from table(abc('a'));Thanks,
    Ronald

    >
    When I create a unit test for this I am not able to specify what the table should contain on return of the function, all I can see is an empty table. Which is off course one of the unit tests. But I also want to test where the table that is returned contains a number of rows.
    Is there something that I'm missing?
    >
    You will have to create a collection that represents the result set and then compare that to the actual result set.
    Assuming tables A and B you would typically have to do
    1. SELECT * FROM A MINUS SELECT * FROM B -- what is in A that is NOT in B
    2. SELECT * FROM B MINUS SELECT * FROM A -- what is in B that is NOT in A
    You could combine those two queries into one with a UNION ALL but since the results are tables and the comparison is more complex it is common to write a function to determine the comparison result.
    Here is sample code that shows how to create an expected result collection.
    DECLARE
    expectedItemList sys.OdciVarchar2List;
    functionItemList sys.OdciVarchar2List;
    newItemList sys.OdciVarchar2List;
    expectedCount INTEGER;
    countFunctionItemList INTEGER;
    BEGIN
    expectedItemList := sys.OdciVarchar2List('car','apple','orange','banana','kiwi');
    expectedCount := 5; -- or query to count them
    functionItemList := sys.OdciVarchar2List('car','apple','orange','peanut');
    -- use your function to get the records
    -- select * from myFunctino BULK COLLECT INTO functionItemList
    IF functionItemList.count != expectedCount THEN
      DBMS_OUTPUT.PUT_LINE('Count is ' || functionItemList.count || ' but should be ' || expectedCount);
    END IF;
    END;
    Count is 4 but should be 5If the collections are the same type you can use the MULTISET operators.
    See Solomon's reply in this thread for how to use the MULTISET operators on collections.
    PLS-00306: wrong number or type of argument in call to 'MULTISET_UNION_ALL'
    See MultisetOperators in the SQL Reference doc
    http://docs.oracle.com/cd/B13789_01/server.101/b10759/operators006.htm
    >
    Multiset operators combine the results of two nested tables into a single nested table.

  • How return parameter ref Cursor from procedure using dynamic SQL?

    I sorry, but i very need help.
    I using Oracle 8.0.6
    I need to return parameter of type ref Cursor from procedure.
    create or replace package PlanExp is
    type cursortype is ref cursor;
    procedure ShowPlan (cursorparam out
    cursortype.............);
    end PlanExp;
    create or replace package body PlanExp is
    procedure ShowPlan (cursorparam out cursortype,
    .............) Is
    sql_str varchar2(1000);
    sql_str_select varchar2(100);
    sql_str_from varchar2(100);
    sql_str_where varchar2(500);
    Return_Code integer;
    Num_Rows integer;
    cur_id_sel integer;
    tSum_Plan DBMS_SQL.NUMBER_TABLE;
    tSum_Plan_Ch DBMS_SQL.NUMBER_TABLE;
    tSum_Plan_Day DBMS_SQL.NUMBER_TABLE;
    begin
    /* calculating string variables ........... /*
    sql_str := 'select ' || sql_str_select ||
    'from ' || sql_str_from ||
    'where ' || sql_str_where ||
    'group by ' || sql_str_select;
    cur_id_sel := dbms_sql.open_cursor;
    dbms_sql.parse(cur_id_sel, sql_str, dbms_sql.native);
    dbms_sql.define_array(cur_id_sel, 1, tSum_Plan, 20, 1);
    dbms_sql.define_array(cur_id_sel, 2, tSum_Plan_Ch, 20, 1);
    dbms_sql.define_array(cur_id_sel, 3, tSum_Plan_Day, 20, 1);
    Return_Code := dbms_sql.execute(cur_id_sel);
    delete from TEMP_SHOWPLAN;
    Loop
    Num_Rows := dbms_sql.Fetch_Rows(cur_id_sel);
    dbms_sql.column_value(cur_id_sel, 1, tSum_Plan);
    dbms_sql.column_value(cur_id_sel, 2, tSum_Plan_Ch);
    dbms_sql.column_value(cur_id_sel, 3, tSum_Plan_Day);
    if Num_Rows = 0 then
    exit;
    end if;
    Exit When Num_Rows < 20;
    End Loop;
    dbms_sql.close_cursor(cur_id_sel);
    end;
    end PlanExp;
    How return cursor (cursorparam) from 3 dbms_sql.column_value-s ?

    I am using Oracle 8.1.7, so I don't know if this will work in
    8.0.6 or not:
    SQL> CREATE TABLE test
      2    (col1                    NUMBER,
      3     col2                    NUMBER,
      4     col3                    NUMBER)
      5  /
    Table created.
    SQL> INSERT INTO test
      2  VALUES (1,1,1)
      3  /
    1 row created.
    SQL> INSERT INTO test
      2  VALUES (2,2,2)
      3  /
    1 row created.
    SQL> INSERT INTO test
      2  VALUES (3,3,3)
      3  /
    1 row created.
    SQL> CREATE TABLE temp_showplan
      2    (tSum_Plan               NUMBER,
      3     tSum_Plan_Ch            NUMBER,
      4     tSum_Plan_Day           NUMBER)
      5  /
    Table created.
    SQL> EDIT planexp
    CREATE OR REPLACE PACKAGE PlanExp
    IS
      TYPE CursorType IS REF CURSOR;
      PROCEDURE ShowPlan
        (cursorparam    IN OUT CursorType,
         sql_str_select IN     VARCHAR2,
         sql_str_from   IN     VARCHAR2,
         sql_str_where  IN     VARCHAR2);
    END PlanExp;
    CREATE OR REPLACE PACKAGE BODY PlanExp
    IS
      PROCEDURE ShowPlan
        (cursorparam    IN OUT CursorType,
         sql_str_select IN     VARCHAR2,
         sql_str_from   IN     VARCHAR2,
         sql_str_where  IN     VARCHAR2)
      IS
        sql_str                VARCHAR2 (1000);
        cur_id_sel             INTEGER;
        return_code            INTEGER;
      BEGIN
        DELETE FROM temp_showplan;
        sql_str := 'INSERT INTO   temp_showplan '
               || ' SELECT '   || sql_str_select
               || ' FROM '     || sql_str_from
               || ' WHERE '    || sql_str_where;
        cur_id_sel := DBMS_SQL.OPEN_CURSOR;
        DBMS_SQL.PARSE (cur_id_sel, sql_str, DBMS_SQL.NATIVE);
        return_code := DBMS_SQL.EXECUTE (cur_id_sel);
        DBMS_SQL.CLOSE_CURSOR (cur_id_sel);
        OPEN cursorparam FOR SELECT * FROM temp_showplan;
      END ShowPlan;
    END PlanExp;
    SQL> START planexp
    Package created.
    Package body created.
    SQL> VARIABLE g_ref REFCURSOR
    SQL> EXEC PlanExp.ShowPlan (:g_ref, 'col1, col2,
    col3', 'test', ' 1 = 1 ')
    PL/SQL procedure successfully completed.
    SQL> PRINT g_ref
    TSUM_PLAN TSUM_PLAN_CH TSUM_PLAN_DAY
             1            1             1
             2            2             2
             3            3             3

  • Using an Oracle procedure that returns three ref cursors

    Is it possible to use an Oracle stored proc that outputs 3 reference cursors to create a BO report?  I can get it to work for one ref cursor only.

    Well, If no one can answer my first question, how about a new one.  Can you join 2 data cubes on a key in a BO report (using 2 Oracle stored procedures)?  For example, I have one cube that has employee beneficiary information and a second cube with what employee coverages the person has.  I need to have a report that displays an employee, thier coverages and then a section that show the employee benefits.  I need a report for each employee (therefore 100 employees= 100 reports) and I can't join the data cubes.  Any help would be appreciated.

  • Querying PL/SQL function which returns SYS_REFCURSOR

    Hello:
    I have a PL/SQL function with return type of SYS_REFCURSOR.
    In SQLPlus, I can query it either as
    var c refcursor
    exec :c := func(...)
    print c
    or
    select func(...) from dual;
    Running the latter in Eclipse 3.3 with oracle DTP extensions installed gives me OracleResultSetImpl object in the SQL Results view.
    Can the code be a little smarter and recognize that a sql query may return "indirect" resultset?
    Regards,
    Ernest

    This is noted; will be the interface better to handle the return values. Thanks

Maybe you are looking for