Problem in opening a ref cursor.

Hi,
I'm getting the following error when i'm trying to open the ref cursor. PL/SQL: ORA-22905: cannot access rows from a non-nested table item
What i'm trying to do is I'm dumping the data into pl/sql table and i want retrieving the by using a ref cursor. Please see the code and help me out.
CREATE OR REPLACE PACKAGE CPS_RECR.pg_pool_status AS
  TYPE pool_rec IS RECORD (
   status  varchar2(50)
  ,stsno number
  ,stscode varchar2(5)
  ,candidatename varchar2(200)
  ,monyear varchar2(10)
  ,yyyymm number
  ,stscnt number
  --type rec_sts_tab is table of number ;--index by pls_integer;
  type pool_tab IS table of pool_rec index by binary_integer;
  type pool_cv is REF CURSOR return pool_rec;
FUNCTION pool_status_query(p_start_date in date,p_end_date in  date,p_invitedtopoolbit  in number,p_showedForPoolBit in  number)
   RETURN pool_tab;--pool_cv ;
  cursor cur_pool(p_start_date date,p_end_date date,p_invitedtopoolbit number,p_showedForPoolBit number)
  is
     SELECT   distinct to_char(date1,'yyyymm')yearmonth
              FROM acs100data a,
                 acs100_candidate_verification b,                
                 acs100_candidate_pool d
             WHERE UPPER (a.basic_email) = UPPER (b.email)
             AND (b.candidate_status IN ('FORL', 'FWRT') or BITAND (b.candidate_status_bit, 4 ) > 0
              or BITAND (b.candidate_status_bit, 2) > 0)                         
             AND d.pool_id = b.pool_id
             AND pool_date BETWEEN p_start_date AND p_end_date
             AND is_tentative_date IS NULL  ;
  cursor cur_name(p_yyyymm varchar2,p_cond number,p_start_date date,p_end_date date)
  is
  select *
  from (select distinct (case
                            when p_cond = 0 and b.candidate_status = 'FORL'
                               then (last_name || first_name)
                            when p_cond = 1 and b.candidate_status = 'FWRT'
                               then (last_name || first_name)
                            when p_cond = 2
                            and bitand (b.candidate_status_bit, p_cond) > 0
                               then (last_name || first_name)
                            when p_cond = 4
                            and bitand (b.candidate_status_bit, p_cond) > 0
                               then (last_name || first_name)
                         end
                        ) candidatename
                   from acs100data a,
                        acs100_candidate_verification b,
                        acs100_candidate_pool d
                  where upper (a.basic_email) = upper (b.email)
                    and d.pool_id = b.pool_id
                    and pool_date between p_start_date and p_end_date
                    and to_char (date1, 'yyyymm') = p_yyyymm
                    and is_tentative_date is null)
where candidatename is not null;  
END pg_pool_status;
CREATE OR REPLACE PACKAGE BODY CPS_RECR.pg_pool_status
AS
   FUNCTION pool_status_query (
      p_start_date         IN   DATE,
      p_end_date           IN   DATE,
      p_invitedtopoolbit   IN   NUMBER,
      p_showedforpoolbit   IN   NUMBER
      RETURN pool_tab--pool_cv
   IS
      tab_pool    pool_tab;
      temp_rf    pool_cv;
      n_index     NUMBER         := 1;
      --rec_sts_data  rec_sts_tab;
      n_stscnt    NUMBER;
      vc_status   VARCHAR2 (100);
      vc_label  varchar2(1000);
      vc_name  varchar2(100);
   BEGIN
      tab_pool.DELETE;
      vc_label :='Opening Pool cursor';
      FOR rec_pool IN cur_pool (p_start_date,
                                p_end_date,
                                p_invitedtopoolbit,
                                p_showedforpoolbit
      LOOP
          if cur_pool%notfound then
            exit;
          end if;
         vc_label :='Opening p_cond cursor';
         FOR p_cond IN 0 .. 3
         LOOP
            n_stscnt := 0;
            vc_status := NULL;
            begin
                SELECT   SUM
                            (NVL
                                (COUNT
                                    (CASE
                                        WHEN p_cond = 0
                                        AND b.candidate_status = 'FORL'
                                           THEN (last_name || first_name)
                                        WHEN p_cond = 1
                                        AND b.candidate_status = 'FWRT'
                                           THEN (last_name || first_name)
                                        WHEN p_cond = 2
                                        AND BITAND (b.candidate_status_bit,
                                                    p_cond) > 0
                                           THEN (last_name || first_name)
                                        WHEN p_cond = 4
                                        AND BITAND (b.candidate_status_bit,
                                                    p_cond) > 0
                                           THEN (last_name || first_name)
                                     END
                                 0
                            ) cnt,
                         DECODE (p_cond,
                                 0, 'FAILED WRITTEN TEST',
                                 1, 'FAILED **** TEST',
                                 2, 'Invited for Pool',
                                 4, 'Showed up for Pool'
                                ) status
                    INTO n_stscnt,
                         vc_status
                    FROM acs100data a,
                         acs100_candidate_verification b,
                         acs100_candidate_pool d
                   WHERE UPPER (a.basic_email) = UPPER (b.email)
                     AND d.pool_id = b.pool_id
                     AND pool_date BETWEEN p_start_date AND p_end_date
                     AND TO_CHAR (date1, 'yyyymm') = rec_pool.yearmonth
                     AND is_tentative_date IS NULL
                GROUP BY candidate_status,
                         b.candidate_status_bit,
                         DECODE (p_cond,
                                 0, 'FAILED WRITTEN TEST',
                                 1, 'FAILED **** TEST',
                                 2, 'Invited for Pool',
                                 4, 'Showed up for Pool'
              exception
                 when no_data_found
                 then
                    n_stscnt :=0;
                    vc_status :=null;
             end;
            vc_label :='Opening name cursor';         
            FOR rec_name IN cur_name (rec_pool.yearmonth,
                                      p_cond,
                                      p_start_date,
                                      p_end_date
            LOOP
               if cur_name%notfound then
               exit;
               end if;
               tab_pool (n_index).yyyymm := rec_pool.yearmonth;
               tab_pool (n_index).stscnt := n_stscnt;
               tab_pool (n_index).status := vc_status;
               tab_pool (n_index).candidatename := rec_name.candidatename;
               dbms_output.put_line('tab_pool(n_index).yyyymm  : '||tab_pool(n_index).yyyymm);
               dbms_output.put_line('tab_pool(n_index).stscnt : '||tab_pool(n_index).stscnt);
               dbms_output.put_line('tab_pool(n_index).status : '||tab_pool(n_index).status);
               dbms_output.put_line('tab_pool(n_index).candidatename : '||tab_pool(n_index).candidatename);
               vc_name :=rec_name.candidatename;
            END LOOP;
            n_index := n_index + 1;
         END LOOP;
      END LOOP;      
      RETURN tab_pool;
   exception
     when others
     then
         dbms_output.put_line('error :'||vc_label||'--'||  vc_name); 
   END;
END pg_pool_status;
---run script
DECLARE
  RetVal CPS_RECR.PG_POOL_STATUS.pool_tab;
  P_START_DATE DATE;
  P_END_DATE DATE;
  P_INVITEDTOPOOLBIT NUMBER;
  P_SHOWEDFORPOOLBIT NUMBER;
temp_cv CPS_RECR.PG_POOL_STATUS.pool_cv;
BEGIN
  P_START_DATE := to_date('09/01/2008','mm/dd/yyyy');
  P_END_DATE := to_date('09/30/2008','mm/dd/yyyy');
  P_INVITEDTOPOOLBIT := 2;
  P_SHOWEDFORPOOLBIT := 4;
  open temp_cv for select * from  table((CPS_RECR.PG_POOL_STATUS.POOL_STATUS_QUERY ( P_START_DATE, P_END_DATE, P_INVITEDTOPOOLBIT, P_SHOWEDFORPOOLBIT )) );
  end loop;
exception
   when others
   then
      dbms_output.put_line(sqlerrm);
END;

Satyaki,
It doesn't help me out. I'm worndering one of code sample is working fine. i didn't my current is giving the problem.
FYI, please see the some code i followed.
SQL> Create or replace PACKAGE cv IS
  2     type comp_rec is RECORD
  3               (deptno number,
  4                ename  varchar(10),
  5                compensation number);
  6     type comp_tbl IS table of comp_rec;
  7     function get_coll return comp_tbl pipelined;
  8     temp_tbl comp_tbl := comp_tbl();
  9     type comp_cv is REF CURSOR return comp_rec;
10  end;
11  /
Package created.
SQL> Create or replace PACKAGE body cv IS
  2     function get_coll return comp_tbl pipelined
  3     is
  4     begin
  5      for i in 1..temp_tbl.count loop
  6       pipe row(temp_tbl(i));
  7      end loop;
  8      return;
  9     end;
10  end;
11  /
Package body created.
SQL> declare
  2     temp_cv cv.comp_cv;
  3     rc cv.comp_rec;
  4  begin
  5           cv.temp_tbl.delete;
  6           cv.temp_tbl.extend;
  7    cv.temp_tbl(1).deptno:=10;
  8    cv.temp_tbl(1).ename:='1223';
  9    cv.temp_tbl(1).compensation:=10;
10  
11          -- erroring out
12   open temp_cv for select * from  table(cv.get_coll);
13          fetch temp_cv into rc;
14          dbms_output.put_line('Deptno is ' || rc.deptno);
15          dbms_output.put_line('ename is ' || rc.ename);
16  end;
17  /
Deptno is 10
ename is 1223
PL/SQL procedure successfully completed.

Similar Messages

  • Problem with accepting the Ref Cursor in c# program

    I am passing an argument as OUT Ref Cursor in a stored procedure. and calling the procedure from my c# program.
    I can connect the database successfully but am getting the error on calling the procedure.
    I am using the ODBC connection
    My procedure's signatures are like:
    CREATE OR REPLACE PACKAGE BODY packageName
    IS
    PROCEDURE GetOutput(returnCursor OUT Sys_RefCursor)
    AS
    BEGIN
    OPEN returnCursor FOR
    <<my select statement>>
    END GetOutput;
    END packageName;
    My function call is like:
    CString Extract::ExtractScript() const
         CString script;
         script.Format("{Call %s.%s()}", packageName,GetOutput);
         return script;
    I can compile the procedure successfully on Toad but while calling the procedure from the C# program it gives following error
    Connection Successful
    Problem executing SQL {Call packageName.GetOutput()}...
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'GetOutput'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    Message was edited by:
    user653288

    Hi Aga,
    Thanks for your response.
    I figured out the problem.
    I was using the ODBC connection which wasnt updated for Oracle 10g.
    I have updated that. Now its working fine.
    Thanks again
    Regards

  • Odd error while opening a ref cursor

    Hi.
    I have a procedure in a package that has both in and out parameters. One of those out parameters is a ref cursor. The procedure creates a dynamic query and then executes it, then it opens the cursor:
    PROCEDURE PROC(
    A IN VARCHAR2,
    B IN VARCHAR2,
    C OUT TYPES.cursorType; --(TYPES is a package whose only use is to declare a cursor type)
    ) IS
    --DECLARATIONS
    OPEN C FOR 'SELECT A, B, C, D...';
    END;
    When I execute the package in an anonymous block it throws the error:
    ORA-00938: not enough arguments for function, just in the line where the cursor is being opened.
    Any ideas?

    is everything defined correctly?
    create or replace package types  as
      type cursorType is ref cursor;
    end types;
    SQL> set serveroutput on
    SQL> declare
      2 
      3    ref_C types.cursorType;
      4   
      5    v_a varchar2(1);
      6    v_b varchar2(1);
      7    v_c varchar2(1);
      8    v_d varchar2(1);
      9   
    10    procedure Proc (a in varchar2
    11                   ,b in varchar2
    12                   ,C out types.cursorType) as
    13 
    14      begin
    15        open C for 'select :1, :2, ''c'', ''d'' from dual' using a, b;
    16    end  Proc;
    17  begin
    18 
    19 
    20    Proc('a', 'b', ref_C);
    21   
    22    fetch ref_C into v_a, v_b, v_c, v_d;
    23    if (ref_C%found) then
    24      dbms_output.put_line(v_a);
    25      dbms_output.put_line(v_b);
    26      dbms_output.put_line(v_c);
    27      dbms_output.put_line(v_d);
    28    end if;
    29   
    30   
    31  end;
    32  /
    a
    b
    c
    dP;
    Edited by: bluefrog on Feb 18, 2010 6:07 PM

  • How to open a Ref cursor in Oracle Reports

    I have a stored procedure that returns a ref cursor as an output parameter. I want to call this stored procedure in Oracle Reports After Form trigger. I am having trouble with the syntax of the output parameter. Event_record is the name of the cursor.
    After Form Trigger
    pkg_DEAL_WHITESHEET_CONCERTS.prc_Event_Information(:p_field_6,event_record);
    Error: Event_record must be declared

    Re-Write the procedure as Package Spec and Body. Declare the REFCursor in the Package Spec. Probably that helps.

  • Opening a ref cursor using CLOB variable

    Is there any way to open a ref cusor using CLOB variable.
    When I am opening on CLOB variable , I am getting an error like 'Missing Expression'
    Please help me

    For 10g...
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    v_large_sql  CLOB;
      3    v_num        NUMBER := 0;
      4    v_upperbound NUMBER;
      5    v_sql        DBMS_SQL.VARCHAR2S;
      6    v_cur        INTEGER;
      7    v_ret        NUMBER;
      8  begin
      9    -- Build a very large SQL statement in the CLOB
    10    LOOP
    11      IF v_num = 0 THEN
    12        v_large_sql := 'CREATE VIEW vw_tmp AS SELECT ''The number of this row is : '||to_char(v_num,'fm0999999')||''' as col1 FROM DUAL';
    13      ELSE
    14        v_large_sql := v_large_sql || ' UNION ALL SELECT ''The number of this row is : '||to_char(v_num,'fm0999999')||''' as col1 FROM DUAL';
    15      END IF;
    16      v_num := v_num + 1;
    17      EXIT WHEN DBMS_LOB.GETLENGTH(v_large_sql) > 40000 OR v_num > 800;
    18    END LOOP;
    19    DBMS_OUTPUT.PUT_LINE('Length:'||DBMS_LOB.GETLENGTH(v_large_sql));
    20    DBMS_OUTPUT.PUT_LINE('Num:'||v_num);
    21    --
    22    -- Now split that large SQL statement into chunks of 256 characters and put in VARCHAR2S array
    23    v_upperbound := CEIL(DBMS_LOB.GETLENGTH(v_large_sql)/256);
    24    FOR i IN 1..v_upperbound
    25    LOOP
    26      v_sql(i) := DBMS_LOB.SUBSTR(v_large_sql
    27                                 ,256 -- amount
    28                                 ,((i-1)*256)+1 -- offset
    29                                 );
    30    END LOOP;
    31    --
    32    -- Now parse and execute the SQL statement
    33    v_cur := DBMS_SQL.OPEN_CURSOR;
    34    DBMS_SQL.PARSE(v_cur, v_sql, 1, v_upperbound, FALSE, DBMS_SQL.NATIVE);
    35    v_ret := DBMS_SQL.EXECUTE(v_cur);
    36    DBMS_OUTPUT.PUT_LINE('View Created');
    37* end;
    SQL> /
    Length:40015
    Num:548
    View Created
    PL/SQL procedure successfully completed.
    SQL> select count(*) from vw_tmp;
      COUNT(*)
           548
    SQL> select * from vw_tmp where rownum <= 10;
    COL1
    The number of this row is : 0000000
    The number of this row is : 0000001
    The number of this row is : 0000002
    The number of this row is : 0000003
    The number of this row is : 0000004
    The number of this row is : 0000005
    The number of this row is : 0000006
    The number of this row is : 0000007
    The number of this row is : 0000008
    The number of this row is : 0000009
    10 rows selected.
    SQL>

  • Problem in using ref cursor

    I have a procedure which is using one ref cursor as OUT paramater. Now when I call this procedure, it gives me the following error:
    ORA-00932: inconsistent datatypes: expected CURSER got NUMBER
    ORA-06512: at "APPS.ORDER_RETURN1", line 8
    ORA-06512: at "APPS.ORDER_RETURN2", line 4
    ORA-06512: at line 1
    Below is my code
    PROCEDURE ORDER_RETURN1(p_order OUT sys_refcursor) IS
    TYPE OE_ORDER_rcur IS REF CURSOR;
    rcur OE_ORDER_rcur;
    BEGIN
    OPEN rcur FOR
    SELECT ORDER_NUMBER FROM OE_ORDER_HEADERS_ALL WHERE ROWNUM < 4;
    FETCH rcur INTO p_order;
    CLOSE rcur;
    END ORDER_RETURN1;
    PROCEDURE ORDER_RETURN2 IS
    OE_ORDER_rcur11 sys_refcursor;
    BEGIN
    ORDER_RETURN1(OE_ORDER_rcur11);
    end;
    I tried to call proc ORDER_RETURN1 with the help of proc ORDER_RETURN2, but no change, it gives me same error if i call the first proc ORDER_RETURN1 or i call ORDER_RETURN2.
    I am stuck with this problem, I had used ref cursor in procedure but not able to call the procedure which uses ref cursor as OUT parameter.
    Please help me to resolve this.
    Thanks
    Nidhi..

    Check out this
    SQL>VARIABLE X REFCURSOR
    SQL>CREATE OR REPLACE PROCEDURE ORDER_RETURN1(p_order OUT sys_refcursor) IS
      2  BEGIN
      3  OPEN p_order FOR
      4  SELECT OBJECT_ID FROM ALL_OBJECTS WHERE ROWNUM < 4;
      5  END ORDER_RETURN1;
      6  /
    Procedure created.
    SQL>EXEC ORDER_RETURN1(:X)
    PL/SQL procedure successfully completed.
    SQL>PRINT X
    OBJECT_ID
             4
            39
            30
    SQL>Regards
    Arun

  • How do i return data, when my sql was opened in a ref cursor.

    In Pl/sql, I was been bunged in the following situation:
    I am opening a ref cursor, where i couldn't determine the return type. In that case how will i return the data for those sql.
    Sample code :
    Declare
    Type a_ref IS REF CURSOR;
    C1 a_ref;
    Begin
    Open c1 for ‘select a, b, c from D’;
    Fetch c1 into ??????;
    Close c1;
    End;
    My doubt resides in ??? part..
    The columns in the select clause will vary dynamically.
    Hence how can I declare my variable..
    Regards,
    Bala

    Well, nothing is over to change mind if possible. I think the knowledge of
    alternatives is always useful... :).
    As for DBMS_SQL, it's an alternative to ref cursors too, but surely inside PL/SQL:
    SQL> declare
      2   c integer;
      3   desc_t DBMS_SQL.DESC_TAB;
      4   col_cnt integer;
      5   type gvarray is varray(25) of varchar(40);
      6   values1 gvarray := gvarray();
      7   a integer;
      8  begin
      9   values1.extend(25);
    10   c := dbms_sql.open_cursor;
    11   DBMS_SQL.PARSE(c,'select hiredate,ename from emp' ,DBMS_SQL.NATIVE);
    12   DBMS_SQL.DESCRIBE_COLUMNS (
    13     c,
    14     col_cnt,
    15     desc_t);
    16   for j in 1..col_cnt loop
    17     dbms_sql.define_column(c,j,values1(j),40);
    18   end loop;
    19   a:=dbms_sql.execute(c);
    20   loop
    21     if dbms_sql.fetch_rows(c) > 0 then
    22      for j in 1..col_cnt loop
    23        dbms_sql.column_value(c,j,values1(j));
    24        dbms_output.put_line('Row number ' || j || ', column ' || desc_t(j).col_name || ', value
    25        || values1(j) );
    26      end loop;
    27     else
    28       exit;
    29     end if;
    30   end loop;
    31   dbms_sql.close_cursor(c);
    32  end;
    33  /
    Row number 1, column HIREDATE, value 17.12.80
    Row number 2, column ENAME, value SMITH
    Row number 1, column HIREDATE, value 20.02.81
    Row number 2, column ENAME, value ALLEN
    Row number 1, column HIREDATE, value 22.02.81
    Row number 2, column ENAME, value WARD
    Row number 1, column HIREDATE, value 02.04.81
    Row number 2, column ENAME, value JONES
    Row number 1, column HIREDATE, value 28.09.81
    Row number 2, column ENAME, value MARTIN
    Row number 1, column HIREDATE, value 01.05.81
    Row number 2, column ENAME, value BLAKE
    Row number 1, column HIREDATE, value 09.06.81
    Row number 2, column ENAME, value CLARK
    Row number 1, column HIREDATE, value 19.04.87
    Row number 2, column ENAME, value SCOTT
    Row number 1, column HIREDATE, value 17.11.81
    Row number 2, column ENAME, value KING
    Row number 1, column HIREDATE, value 08.09.81
    Row number 2, column ENAME, value TURNER
    Row number 1, column HIREDATE, value 23.05.87
    Row number 2, column ENAME, value ADAMS
    Row number 1, column HIREDATE, value 03.12.81
    Row number 2, column ENAME, value JAMES
    Row number 1, column HIREDATE, value 03.12.81
    Row number 2, column ENAME, value FORD
    Row number 1, column HIREDATE, value 23.01.82
    Row number 2, column ENAME, value MILLER
    PL/SQL procedure successfully completed.Rgds.

  • Reports 3.0, Ref Cursor from stored procedure

    I have a problem trying to use Ref Cursor as datasource (i.e.
    Ref Cursor Query) in Reports 3.0
    I have created a stored package with a function which returns
    Ref Cursor.
    That function just opens the cursor and returns it to the
    calling module.
    Reports recognizes returned cursor - it creates a group for that
    query, with all columns, than I built
    a layout model - everything is OK on that stage.
    During the execution of that report (from previewer or using
    Reports Runtime) I got an error message like that:
    REP-0065 Virtual Memory System Error
    REP-0200 Cannot allocate enough memory cavaa22
    Error's description does not correspond the reality :) - there
    is enough virtual & physical memory according to
    Task Manager information.
    So, that does not work when this package is stored one.
    When I create the package on the client side - in Reports -
    everything works just fine.
    Cursor is opened with a very simple query, selecting records
    from the very simple table having only one record.
    There is no code written which closes that cursor or fetches the
    records.
    Client platform: WinNT 4.0 SP3
    Oracle Reports: 3.0.5.8.0
    Oracle Server: Oracle8 8.0.5.0.0 (and I tried also on Oracle7
    7.3.4.3.0)
    Thanx.
    null

    Sara,
    GTT (Global Temporary Tables) in Oracle work a different way compared to SQL Server and Informix. There you can create temporary tables on the fly and drop them on the fly.
    Here you should (note, you don't have to, but, best practice says that you should) create the table using the syntax...
    create global temporary table.....
    Once you create it, even though it looks like persistent table, it's not. It will have it's own individual data PER SESSION . You have two types of GTTs:
    ON COMMIT PRESERVE ROWS and ON COMMIT DELETE ROWS (they work in slightly different way).
    Look up GTTs here:
    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14231/tables.htm#sthref2213
    HTH,
    Rahul

  • Populate a REF CURSOR from regular cursor...

    Hi all,
    I apologize if the answer to this is somewhere...I've been looking on the web for sometime and can't find an answer to the following problem. I have a Significant Events database that contains network based issues and problems. As problems are detected on the network an SE is issued and published. As the SE records are updated, NEW records are entered into the table and "linked" back to the original. Each update results in a new row. Thus, an SE with two updates would have a total of 3 lines. When the SE gets closed (set the column CLOSED to SYSDATE), only the "original" SE is closed, any updates are left open...aka, the CLOSED column is left null.
    That said, I need a way to get the original and/or latest updated SE rows from the table. Thus, I am trying to use a PL/SQL package. The PL/SQL "must" return a REF CURSOR as the results are being passed to a client process.
    My initial approach was within a PL/SQL procedure, I have an SQL statement that returns the SE originals. Once in that cursor I need to do the following:
    - Attempt to fetch any linked SE rows.
    - if no rows then
    - add the original to the REF CURSOR.
    - else
    - find latest SE update
    - add latest SE update to REF CURSOR.
    - end if
    My Question is : How do I manually "add" a row to a REF CURSOR?
    If this is not possible, is there a way to populate a REF CURSOR from maybe another construct like:
    TYPE ian_se_record is RECORD (
    se_id number
    ,linked_se_id number
    ,submitted date
    ,updated date
    ,closed date
    ,segroup varchar2(150)
    ,incident_start_time varchar2(150)
    ,business_units_affected varchar2(150)
    ,officenum varchar2(1500)
    ,sedetails varchar2(4000)
    TYPE ian_se_table is table of ian_se_record index by binary_integer;
    With the above construct I could:
    - Fill ian_se_table with the process described above.
    - And finally select off ian_se_table into the REF CURSOR?
    Any help would be greatly appreciated,
    adym

    Hi michaels,
    I've put your solution in place, but can't seem to get it to run. The two types were moved out of the package and into real types as you said. Here's the function, for brevity, I've remove some of the less important code:
    function ian_se_fetch return sys_refcursor
    is
        p_csr_events            sys_refcursor;
        cursor csr_items is
            select
                 se_id
        ...removed for brevity...
        /* END : csr_items  */
        ian_se_row     ian_se_record;
        ian_se_tbl     ian_se_table;
        l_lng_index    number;
        l_lng_linked   number;
        l_lng_id       number;
    begin
         * OPEN : Open the main cursor of originals...
        for the_item in csr_items loop
             * CHECK : Check for any updates to the original...
            l_lng_linked := 0;
            select count(*)
            into l_lng_linked
            from sig_se_t src
            where src.linked_se_id = the_item.se_id;
            l_lng_id := 0;    /* reset the se-id    */
            /* SE original...no linked records yet.    */
            if ( l_lng_linked = 0 ) then
                l_lng_id := the_item.se_id;
            /* SE updates...one or more updates are present.    */
            else
                begin
                    select
                         se_id
                    into l_lng_id
                    from sig_se_t src
                    where src.linked_se_id = the_item.se_id
                      and rownum = 1
                    order by updated desc; /* latest update    */
                exception
                    when too_many_rows then
                        l_lng_id := the_item.se_id;
                    when others then
                        l_lng_id := 0;
                end;
            end if;
            if ( l_lng_id != 0 ) then
                select
                     se_id
                    ,linked_se_id
                    ,submitted
                    ,updated
                    ,closed
                    ,segroup
                    ,incident_start_time
                    ,business_units_affected
                    ,officenum || decode( nvl(impact,'1')
                                      ,'1',''
                                      ,decode(impact
                                          ,'NA', ''
                                          ,':' || impact
                                  )                           impact
                    ,sedetails
                into ian_se_row.se_id
                    ,ian_se_row.linked_se_id
                    ,ian_se_row.submitted
                    ,ian_se_row.updated
                    ,ian_se_row.closed
                    ,ian_se_row.segroup
                    ,ian_se_row.incident_start_time
                    ,ian_se_row.business_units_affected
                    ,ian_se_row.officenum
                    ,ian_se_row.sedetails
                from sig_se_t src
                where src.se_id = l_lng_id;
                l_lng_index := nvl(ian_se_tbl.last,0)+1;
                ian_se_tbl(l_lng_index).se_id                   := ian_se_row.se_id;
                ian_se_tbl(l_lng_index).linked_se_id            := ian_se_row.linked_se_id;
                ian_se_tbl(l_lng_index).submitted               := ian_se_row.submitted;
                ian_se_tbl(l_lng_index).updated                 := ian_se_row.updated;
                ian_se_tbl(l_lng_index).closed                  := ian_se_row.closed;
                ian_se_tbl(l_lng_index).segroup                 := ian_se_row.segroup;
                ian_se_tbl(l_lng_index).incident_start_time     := ian_se_row.incident_start_time;
                ian_se_tbl(l_lng_index).business_units_affected := ian_se_row.business_units_affected;
                ian_se_tbl(l_lng_index).officenum               := ian_se_row.officenum;
                ian_se_tbl(l_lng_index).sedetails               := ian_se_row.sedetails;
            end if;
        end loop;
         * REF CURSOR : Open the ref cursor on the dataset...
        if ( nvl(ian_se_tbl.last,0) = 0 ) then
            p_csr_events := null;
        else
            open p_csr_events for
            select *
            from table (cast ( ian_se_tbl as ian_se_table ));
        end if;
        return p_csr_events;
    end;Here's the test. I keep getting the same error ORA-06530:
    SQL> variable v refcursor;
    SQL> exec :v:=pkg_ian.ian_se_fetch;
    BEGIN :v:=pkg_ian.ian_se_fetch; END;
    ERROR at line 1:
    ORA-06530: Reference to uninitialized composite
    ORA-06512: at "N0002501.PKG_IAN", line 131
    ORA-06512: at line 1
    SQL> print v
    ERROR:
    ORA-24338: statement handle not executedOther things I tried:
    - The ian_se_fetch() function was a procedure using an in out parameter...same error.
    - Wrote a small anonymous block and tried to LOOP/FETCH. Same ORA-06530 error.
    P.S. Line 131 of pkg_ian is the SELECT ... INTO ian_se_row.se_id, ...
    Any help would be greatly appreciated,
    tia,
    adym
    Message was edited by:
    alink

  • Using ref cursor in after parameter form in reports

    hi everyone,
    I have problem in usage of ref cursor in after parameter form. My actual requirement is I have user parameter :p_minval, :p_maxval. The values into these user parameters will be coming dynamically using sql_statement as shown below
    select min(empid),max(empid) into :p_minval, :p_maxval from emp where empid in (:p_emp);
    I will be writing this query in the after parameter form
    :p_emp is a lexical parameter as per me but the after parameter form is taking it as a bind variable. so I decided to define a ref cursor and then use it for retrieve. But when I use ref cursor it is returning pl/sql error 591 saying that this is not supported by client side can anyone help me plz..
    The following is the code i tried to use in after parameter form
    function afterPform return boolean is
    type rc is ref cursor;
    l_rc rc;
    sqlstmt varchar2(512);
    begin
    sqlstmt:='select min(empid),max(empid) from emp where empid in ('||:p_emp||')';
    open l_rc for
    select max(empid) from emp where empid in ('||:p_emp||')';
    fetch l_rc into :p_maxval;
    close l_rc;
    return(true);
    end;
    thanks & regards
    venkat

    I ran into the same problem. any body knows why?

  • Ref cursor from anonymous block

    I have no problem to get a ref cursor from a Fill method call with an anonymous pl/sql block. But if my anonymous block contains a DECLARE section, the dataset is not populated.
    ex:
    BEGIN OPEN :cuInscription FOR SELECT column FROM table; END;
    is ok but with
    DECLARE A NUMBER; BEGIN OPEN :cuInscription FOR SELECT column FROM table; END;
    the dataset is not populated (even if the SQL CALL succeed).
    Do you know about that?

    This issue has been fixed in the ODP.NET 92040 release.

  • Forms Data-Block based on stored procedures - REF CURSOR feature NOT FUNCTIONING

    This topic is related to another topic in this forum titled "FORMS HOW TO SET QUERY SOURCE ARGUMENTS??" I posted my message there as well. I am posting as a NEW TOPIC so that it catches the attention of Oracle Support.
    I built a data form based on a stored procedure and REF CURSOR IN OUT parameter.
    My procedure takes a IN parameter to fill in the criteria for the OPEN <cursor_variable> select ... where ... statement.
    In the Value setting of the Query source Arguments , I set the VALUE to ":BLOCK_NAME.ITEM_NAME" at design time to supply the input value to the procedure. this works to the extent of making available the form item value to the stored procedure parameter. I verified this by doing an insert into some debug table , of the incoming parameter value inside my stored procedure.
    The cursor gets opened properly into the REF cursor variable. I verified this by fetching a record into a local variable and inserting the value into a debug table again in the stored procedure.
    (I took care to close and re-open the REF cursor variable again - so that the front-end can continue to fetch it from the first record. )
    ***** PROBLEM **************
    But the front end forms runtime is giving me a FRM-40301 - query returned no records even though the REF cursor is returned properly opened.
    Did anybody else face the same problem ??
    Please post what you found.
    Thanks,
    Shankaran
    null

    This topic is discussed at length in another thread "How Set Value For Query DataSource Arguments?"
    But I am posting the findings here as well.
    THIS TOPIC IS CLOSED.
    My Bad. The problem Cause : I did not include all columns in the
    cursor rowtype in the Data-block. In the wizard for the data block , I selected ONLY the columns that I needed. But I was doing a Select * from <my_table> in my open cursor <Cursor-Variable> .... The <Cursor Variable>
    itself was declared <my_table>%rowtype
    FIX : The Data Block structure (columns included as items) should match the cursor record Structure. One may or may not
    display all the columns in the LAYOUT though.
    But I don't understand why it gives such a misleading message like FRM-40301 Query retrieved no records. Oracle Team fix it.
    Hope this helps people who face the same problem.
    Thanks,

  • Stored procedure - ref cursor - no rows

    Hello,
    I am stumped. Hopefully another pair of eyes will see what mine cannot. I am calling a stored procedure that accepts a single output parameter [the proc has been dumbed down to limit variables of my problem] that is a ref cursor. When I make the call I get now data. I have used both adapter and datareaders. If I call the proc from another proc I can loop through the results. I am including the code of my c# function and the stored proc.
    The version number of my Oracle.DataAccess.dll is 10.1.0.303.
    ** Stored Proc ***********************
    TYPE refcursor is ref cursor ;
    procedure P_CUSTOMER_INFO_GET_SLIM( thecur out refcursor )
    is
    begin
    open thecur for
    select *
    from customer_info
    where rownum < 21;
    end P_CUSTOMER_INFO_GET_SLIM;
    ** C# Func ***************************
              private DataSet _FetchCustomerData2(string CustNbr, string ShipToSuffix)
                   string                         sc = "PKG_CUSTOMER_CONTACT.P_CUSTOMER_INFO_GET_SLIM";
                   OracleConnection     con = new OracleConnection(_Database.GetConnection().ConnectionString);
                   OracleCommand               cmd = new OracleCommand(sc, con);
                   OracleDataAdapter da = new OracleDataAdapter(cmd);
                   DataSet ds = new DataSet();
                   // must pass strings with data
                   if (CustNbr.Length==0 || ShipToSuffix.Length==0)
                        return null;
                   try
                        // we are calling a stored proc so set it
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("thecur", OracleDbType.RefCursor, DBNull.Value, ParameterDirection.Output);
                        da.Fill(ds, "Customer"); // no data ?????????????????
                        // Close and Dispose OracleConnection object
                        con.Close();
                        con.Dispose();
                        return ds;

    Hey all,
    I ended up declaring a variable in the proc as refcursor and opening it. Then I assigned the out parameter ref cursor to the variable. That took care of it. See below.
    Thanks,
    Mike
    procedure P_CUSTOMER_INFO_GET(
    CustomerNumber in varchar2
    ,ShipToSuffix in varchar2
    ,thecur out refcursor
    is
    -- variable declarations
    mycur refcursor;
    begin
    open mycur for
    select CORP_CODE
    ,CUST_NUMBER
    ,CUST_SHIP_TO_SFFX
    ,CUST_BILL_TO_SUFF
    ,CUST_AR_OFF_CODE
    ,CUST_NAME
    ,CUST_SHIP_BILL_IND
    ,CUST_SHIP_VIA_CODE
    ,CUST_CLASS_CODE
    ,CUST_TYPE_CODE
    ,CUST_PRICE_CODE
    ,DISC_MKUP_CODE
    ,TRADE_DISC_CODE
    ,CUST_N_D_ACCT_NO
    ,CUST_PRY_PRICE_AGR
    ,CUST_ADDR_1
    ,CUST_ADDR_2
    ,CUST_ADDR_3
    ,CUST_CITY
    ,CUST_STATE
    ,CUST_ZIP
    ,CUST_COUNTRY_CODE
    ,CUST_FAX_NO
    ,CUST_FAX_NO_EXP
    ,CUST_PHONE_NO
    ,CUST_PHONE_NO_EXP
    ,CUST_CRDT_LIM_CODE
    ,CUST_CREDIT_STATUS
    ,CUST_CRED_CARD_NO
    ,CUST_CC_EXP_DATE
    ,CUST_DUNNING_FLAG
    ,CUST_ID
    ,CUST_SP_FILE_IND
    ,CUST_ST_TAX_CODE
    ,LAST_MAINT_DATE
    from customer_info
    where CUST_NUMBER = CustomerNumber
    and CUST_SHIP_TO_SFFX = ShipToSuffix;
    -- send the cursor back
    thecur := mycur;

  • Ref cursors and dynamic sql..

    I want to be able to use a fuction that will dynamically create a SQL statement and then open a cursor based on that SQL statement and return a ref to that cursor. To achieve that, I am trying to build the sql statement in a varchar2 variable and using that variable to open the ref cursor as in,
    open l_stmt for refcurType;
    where refcurType is a strong ref cursor. I am unable to do so because I get an error indication that I can not use strong ref cursor type. But, if I can not use a strong ref cursor, I will not be able to use it to build the report based on the ref cursor because Reports 9i requires strong ref cursors to be used. Does that mean I can not use dynamic sql with Reports 9i ref cursors? Else, how I can do that? Any documentation available?

    Philipp,
    Thank you for your reply. My requirement is that, sometimes I need to construct a whole query based on some input, and sometimes not. But the output record set would be same and the layout would be more or less same. I thought ref cursor would be ideal. Ofcourse, I could do this without dynamic SQL by writing the SQL multiple times if needed. But, I think dynamic SQL is a proper candidate for this case. Your suggestion to use lexical variable is indeed a good alternative. In effect, if needed, I could generate an entire SQL statement and place in some place holder (like &stmt) and use it as a static SQL query in my data model. In that case, why would one ever need ref cursor in reports? Is one more efficient over the other? My guess is, in the lexical variable case, part of the processing (like parsing) is done on the app server while in a function based ref cursor, the entire process takes place in the DB server and there is probably a better chance for re-use(?)
    Thanks,
    Murali.

  • Sorting records dynamically in REF cursor, based upon a dynamic field

    Hi,
    I have a REF CURSOR built by using row type, table type and PIPELINE function. I have opened the ref cursor now. I would like to update a field called 'RANK' based upon 'RATIO' field in the REF CURSOR. i.e order the records in the ref cursor by RATIO field and then update the RANK as 1, 2, 3, 4, ....
    Aim: I want to update a field in the REF CURSOR based upon another numeric field.
    Please help me.
    OPEN sales FOR
    SELECT RANK, ratio
    FROM TABLE (fngetfundholdingsale (in_primarykey, in_flag));
    loop
    fetch sales into sale1;
    exit when sales%notfound;
    --I want to update sale1.rank based upon ratio
    end loop;
    Thanks
    Ashok

    Try to use NDS (Native Dynamic SQL):
    l_order := 'ratio';
    OPEN sales FOR
    'SELECT rank' ||
    '  FROM TABLE (fngetfundholdingsale (:in_primarykey, :in_flag))' ||
    ' ORDER BY ' || l_order
      USING in_primarykey, in_flag;Regards,
    Zlatko

Maybe you are looking for

  • Java.lang.StackOverflowError in KM

    Hi All I am following the menu : System Administration > System Configuration > Knowledge management > Content Management > Action > Check configuration. It is giving the <b>following error</b> : The following objects have invalid settings: .../Prope

  • What app would I use to create an online report like this?

    What Adobe CC app would I use to create a web based report like this? http://sowc2015.unicef.org Could it be done with Muse or does it need something like Dreamweaver and bespoke coding?

  • Compiler Error Message: CS0433

    Compiler Error Message: CS0433: The type 'CrystalDecisions.Web.CrystalReportPartsViewer' exists in both 'c:\WINDOWS\assembly\GAC_MSIL\CrystalDecisions.Web\11.5.3700.0__692fbea5521e1304\CrystalDecisions.Web.dll' and 'c:\WINDOWS\assembly\GAC_MSIL\Cryst

  • SGA, PGA & RAM Size?

    our DB running in dedicated server mode(FYI). am defining my SGA size 500MB, which is half the size of DB server 1gb RAM, it does not mean that my instance will not go beyond 500mb, if multiple users are connected & start using Sorts,(SORT_AREA_SIZE

  • Just upgraded from '08 to '09, and it's messed some things up...

    Hi people. I've just upgraded to iLife '09 from '08, and it seems that some of my webpages have been messed up. Basically, I used to use Filezilla to upload my website, but I thought i'd give iWebs built in FTP a go. Have a look at the screenshots he