Refcursor issue...

Hi All ,
AM having a record type in a pkg spec like .....
TYPE planned_actual_rec IS RECORD (
        study_id                     studies.study_id%TYPE,
        study_name                   studies.study_name%TYPE,
        protocol                     studies.protocol%TYPE,
        sponsor_name                 sponsor.sponsor_name%TYPE,
        country                      sites.country%TYPE,
        pi_name                      VARCHAR2(100),
        study_site                   sites.study_site%TYPE,
        site_participation_status    sites.site_participation_status%TYPE,
        visit_type                   site_visit_xref.visit_type%TYPE,
        visit_seq                    site_visit_types.visit_seq%TYPE,
        cra_name                     VARCHAR2(100),
        tot_patients                 NUMBER,
        projected_date               site_visit_xref.projected_date%TYPE,
        planned_date                 site_visit_xref.planned_date%TYPE,
        visit_start_date             site_visit_xref.visit_start_date%TYPE,
        visit_date                   site_visit_xref.visit_date%TYPE,
        out_of_window                NUMBER,
        visit_description            site_visit_types.description%TYPE,
        site_visit_number            sites_visit_schedule.site_visit_number%TYPE,
          site_visit_alias             sites_visit_schedule.site_visit_alias%type default null --added by kapil on 10-oct-2007
TYPE planned_actual_cur IS REF CURSOR RETURN  planned_actual_rec;And am using this refcursor in so many queries...now my issue is for one of the application i need refcusor to return an additional column(site_visit_alias)...but this disturbs the other procedures where i dont want to use that column and they get invalid...i cant change each and every procedure where am already using this refcursor..IS there any way to achive that??
Thanks
Kapil

Hi riedelme
I have modified the definition of record,,,and since the refcusor is based on the record type ..so issue is in some of the queries am not i want only few of the columns in the ref cursor and in some am using all the columns of ref cursor...example
OPEN rset FOR
    SELECT svx.study_id,
           study_name,
           protocol,
           sponsor_name,
           sites.country,
           iv.last_name || ', ' || iv.first_name || ' ' || iv.middle_initial AS pi_name,
           study_site,
           site_participation_status,
           visit_type,
           visit_seq,
           DECODE(au.last_Name||au.first_name, NULL, NULL, au.last_name || ', ' ||
             au.first_name || ' ' || middle_name) AS cra_name,
           cnt.tot_pat_count AS tot_patients,
           projected_date,
           planned_date,
           visit_start_date,
           visit_date,
           pkg_reports.get_working_days_count_visit(visit_date, projected_DATE,
                                                    planned_date, svx.visit_id) AS out_of_window,
           site_visit_types.description || ' ' || svx.site_visit_number AS visit_description,
           svx.site_visit_numberIn this am having one less column so all the procedures where am having this kind of select...they will become invalid!!
THis is my issue.
Kapil

Similar Messages

  • Problem in passing ref cursor values as parameter in where clau.Most Urgent

    Problem:
    1) I have used normal cursor (C_hubmsgid_set) with some select statement such as grouping and all.
    After executing the query it will return some resultset to the specified cursor.
    2) I am trying to use another cursor which is ref cursor but the problem is
    I want to give all the resultset based on all the conditions to the ref cursor.
    But the cursor will get only the last record due to overwriting .how to get all
    the result set in a ref cursor like
    cursor c1 is select .....
    loop
    open refcursor for
    Select * from ....where condition
    end loop
    After this the refcursor( p_sysaudithistory_cur) which should have all the resultset matched by the where condition.
    3. It should be java compatible one.
    4. I am not able to match cursor row = IN Pameter value
    Below is the query:
    CREATE OR REPLACE PROCEDURE SP_TEST_audit_history2 (
    p_start IN date,
    p_end IN date,
    p_msgcode IN varchar2,
    p_partnername IN varchar2,
    p_status IN varchar2,
    p_locationname IN varchar2,
    p_custbusunit IN varchar2,
    p_sysaudithistory_cur OUT plutotypes.ref_cursor,
    p_status1 OUT NUMBER) AS
    l_status NUMBER := 0;
    CURSOR C_hubmsgid_set IS
    SELECT DISTINCT MAX(tfm.datetime) datetime, tfm.hubmsgid
    FROM tfm_status tfm, vw_msgcode_part_locn vw
    WHERE
    tfm.datetime >= NVL(p_start, TO_DATE('01/01/1981','DD/MM/YYYY')) AND
    tfm.datetime <= NVL(p_end, TO_DATE('31/12/9999','DD/MM/YYYY')) AND
    tfm.msgcode LIKE NVL(p_msgcode,'%') AND
    vw.msgcode = tfm.msgcode
    AND vw.partnername LIKE NVL(p_partnername,'%')
    AND tfm.status LIKE NVL(p_status,'%')
    AND vw.locationname LIKE NVL(p_locationname,'%')
    AND vw.custbusunit LIKE NVL(p_custbusunit,'%')
    AND rownum < 250
    GROUP BY tfm.hubmsgid
    ORDER BY datetime DESC;
    /* Loop through the Cursor */
    BEGIN
    BEGIN
    OPEN p_sysaudithistory_cur
    FOR
    SELECT
    tfm.hubmsgid ,
    tfm.status || '-'|| nvl2(tfm.exception_id,'FAILED','OK') ,
    tfm.datetime,
    tfm.exception_id
    FROM tfm_status tfm
    WHERE tfm.hubmsgid = c_hubmsgids.hubmsgid /* here only i am getting error*/
    AND tfm.datetime = c_hubmsgids.datetime
    AND tfm.status like NVL(p_status,'%')
    and rownum =1;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    l_status := 1;
    END;
    p_status1 := l_status;
    END;
    Thanks in advance
    prasanth a.s.

    Please don't post duplicate questions. All it does is clutter the forums and result in fragmented threads and duplicate responses. Please see my response in the original thread at the link below.
    Please solve this Refcursor issue PLEASE

  • Issue with IN parameter of Oracle Procedure returning two RefCursors...

    Hi all,
    I'm having a nightmare with an Oracle procedure that takes one input parameter and returns two RefCursors as outputs. I recently got help in this forum getting a procedure to work that took no inputs but returned two refcursors and that's still working fine. So, for my current issue I have a procedure defined as follows:
    PROCEDURE getQueueInfo(domainKey char, importQueues OUT ODPNet.refcur, exportQueues OUT ODPNet.refcur) IS
      BEGIN
        OPEN importQueues FOR SELECT
        source_key, source_applid,
        import_status(source_key) as status,
        time_added, time_processed
        FROM wm_import_source_header
        WHERE source_id = domainKey
        ORDER BY source_key DESC;
        OPEN exportQueues FOR SELECT
        h.source_key, d.source_applid,
        export_status(h.source_key) as status,
        d.source_wire_code, d.destination_wire_code, h.time_added,
        h.time_transmitted
        FROM wm_export_source_header h, wm_export_source_data d
        WHERE h.source_key = d.source_key
          and d.source_id = domainKey
        ORDER BY h.source_key DESC;
      END getQueueInfo;This is defined within a package called ODPNet as with my previous procedure and all works fine (I can execute within Oracle SQL Developer and it returns the expected results). Within my .NET application my code is as follows:
                try
                    using (OracleConnection conn = new OracleConnection(connString))
                    using (OracleCommand comm = new OracleCommand())
                        comm.CommandText = "ODPNet.getQueueInfo";
                        comm.CommandType = CommandType.StoredProcedure;
                        comm.Connection = conn;
                        OracleParameter domainKey = new OracleParameter();
                        OracleParameter importQueues = new OracleParameter();
                        OracleParameter exportQueues = new OracleParameter();
                        domainKey.OracleDbType = OracleDbType.Char;
                        importQueues.OracleDbType = OracleDbType.RefCursor;
                        exportQueues.OracleDbType = OracleDbType.RefCursor;
                        domainKey.Value = "UKBD72";
                        domainKey.Direction = ParameterDirection.Input;
                        importQueues.Direction = ParameterDirection.Output;
                        exportQueues.Direction = ParameterDirection.Output;
                        comm.Parameters.Add(domainKey);
                        comm.Parameters.Add(importQueues);
                        comm.Parameters.Add(exportQueues);
                        conn.Open();
                        comm.ExecuteNonQuery();
                        OracleDataReader dr1 = ((OracleRefCursor)importQueues.Value).GetDataReader();
                        OracleDataReader dr2 = ((OracleRefCursor)exportQueues.Value).GetDataReader();
                        if (dr1.HasRows)
                            while (dr1.Read())
                                result6 += dr1["source_applid"].ToString() + "<br>";
                        else
                            result6 += "No Rows";
                        if (dr2.HasRows)
                            while (dr2.Read())
                                result7 += dr2["source_applid"].ToString() + "<br>";
                        else
                            result7 += "No Rows";
                catch (Exception ex)
                    result6 = ex.ToString();
                }The value I want to submit as the IN parameter of the procedure is "UKBD72". but I'm really not sure how to apply this and then return my two refcursors into separate datareaders (except for the input parameter stuff the code above is exactly what I did with the other procedure that returned two ref cursors and still works fine). When I run this code I get no errors, I just get told that each DataReader has no rows returned, which shouldn't be right.
    Any help with this would be hugely appreciated.
    Cheers,
    Seb

    Sorry folks, after staring at this over and over, eventually going to sleep and coming back to it with some fresh eyes I realised I was just being a complete idiot - I was feeding the procedure different data in the .NET app than I was when testing in Oracle SQL Developer. Low and behold once I gave it the right data it worked!
    Silly me...

  • Having issues with bind variable refcursor

    Hi,
    I have a procedure which returns just the list of employees from the emp table.
    while executing this package, it gives me an error
    Ex:
    sql> variable cur refcursor;
    sql> exec emp.getemplist(:cur);
    error:
    not all variables bound
    Please let me know what is wrong here.
    Thanks
    Manju

    manjukn wrote:
    package is a simple one..
    Exact Oracle version? Works fine on 10.2.0.4.0:
    SQL> create or replace package body emp_pkg is
      2  PROCEDURE getemplist (result_cursor OUT sys_refcursor)
      3  IS
      4  begin
      5  open result_cursor for select * from emp where deptno=10;
      6  end getemplist;
      7  end emp_pkg;
      8  /
    Package body created.
    SQL> variable cur refcursor;
    SQL> exec emp_pkg.getemplist(:cur);
    PL/SQL procedure successfully completed.
    SQL> print cur
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
          7839 KING       PRESIDENT            17-NOV-81       5000                    10
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
    SQL> SY.

  • I found out issue distinct clause in query ,refcursor not returning rows

    URGENT
    hi the following procedure returns records  but when i add  distinct clause to (open v_refcursor for select )
    i.e   open v_refcursor for select distinct column1,column2   .......... in the procedure the procedure is not returning records. please help what is the issue here?
    CREATE OR REPLACE procedure proc_shared_report3 (in_cust_id varchar2,in_user_array user_tab , in_acct_array acct_tab,in_report_pvlg_hier varchar2,in_fmt_pvlg_hier varchar2,v_refcursor OUT sys_refcursor)
    is
    BEGIN
    if  in_acct_array.count>0 and in_fmt_pvlg_hier is not null and in_cust_id is not null and in_user_array.count>0 and in_report_pvlg_hier is not null  then
    dbms_output.put_line('all are not null');
    *open v_refcursor for  select usr_id* from vw_get_user_profile where usr_id in (
            SELECT USR_ID FROM VW_GET_ACCOUNTS WHERE USR_ID IN (SELECT distinct up1.usr_id FROM vw_get_user_privileges up1,vw_get_user_privileges up2  WHERE 
            up1.usr_id=up2.usr_id and
            up1.product_hierarchy=in_report_pvlg_hier  and up2.PRODUCT_HIERARCHY=in_fmt_pvlg_hier AND up1.usr_id in (select usr_id from vw_get_user_for_customer where
            cust_id=in_cust_id)
            and up1.usr_id Member Of in_user_array) AND acct_nb Member of in_acct_array);
    /* if account list is null and rest all  not  null */
    elsif (in_acct_array is null or in_acct_array IS EMPTY or in_acct_array.count = 0) and in_fmt_pvlg_hier is not  null  and in_cust_id is not null and in_user_array.count>0 and in_report_pvlg_hier is not null  then
    dbms_output.put_line('acc is null and rest are not null');
    *open v_refcursor for select usr_id,usr_type_cd* from vw_get_user_profile where usr_id in(SELECT  distinct up1.usr_id FROM vw_get_user_privileges up1,vw_get_user_privileges up2  WHERE 
              up1.usr_id=up2.usr_id and
              up1.product_hierarchy=in_report_pvlg_hier and up2.PRODUCT_HIERARCHY=in_fmt_pvlg_hier AND   up1.usr_id in (select usr_id from vw_get_user_for_customer where
              cust_id=in_cust_id)
              and up1.usr_id Member Of in_user_array);
    /* if account list is null and format pvlg hierarchy is null */
    elsif  (in_acct_array is null or in_acct_array IS EMPTY or in_acct_array.count = 0) and in_fmt_pvlg_hier is null and in_cust_id is not null and in_user_array.count>0 and in_report_pvlg_hier is not null
    then
    dbms_output.put_line('acc is null and format is null null');
    *open v_refcursor for select usr_id,tmzon_cd* from vw_get_user_profile where usr_id in (
      (SELECT  distinct usr_id FROM vw_get_user_privileges  WHERE  product_hierarchy=in_report_pvlg_hier  AND   usr_id in (select usr_id from vw_get_user_for_customer where
       cust_id=in_cust_id)
       and usr_id Member Of in_user_array))  ;
    /* if account list is not null and format pvlg hierarchy is  null */
    else  -- If i get only one privilege and all other inputs then 
    dbms_output.put_line('acc list is not null and format pvlg is null');
    *open v_refcursor for select usr_id,prod_shrt_nm* from vw_get_user_profile where usr_id in (
         SELECT USR_ID FROM VW_GET_ACCOUNTS WHERE USR_ID IN (SELECT  distinct usr_id FROM vw_get_user_privileges  WHERE 
         product_hierarchy=in_report_pvlg_hier  AND   usr_id in (select usr_id from vw_get_user_for_customer where
         cust_id=in_cust_id) and usr_id Member Of in_user_array ) AND acct_nb Member of in_acct_array);
    END IF;
    END proc_shared_report3;
    /Edited by: raj_fresher on Aug 12, 2009 8:50 AM
    Edited by: raj_fresher on Aug 12, 2009 1:40 PM

    its like this ...... ?
    You have to understand that without any testdata/ a reproducable testcase, all I can do is asking you to test some alternatives, I'm just guessing things from what I can make of your example, and hope you'll repost back any differences in a clear and concisive way.
    What I didn't understand is why you're not just joining your tables/views instead of using inner queries.
    Unfortunatly you're not providing any feedback on that, on the other hand you've narrowed down your problem to a specific part of your query? But you're not sharing why/what makes you decide to take that turn.
    But: you're still using inner queries in your reply.
    So, sorry, I cannot proceed/say anything useful unless you answer my previous post.
    Because, there are still many other questions/doubts: I don't understand why you're not aliasing your columns properly, for example.
    I don't know why you've suddenly switched to VW_GET_USER_cust_sa?
    I don't know if you've tried the straight join instead of nesting queries?
    And if you did, what's the problem?
    Please read and understand this, so you'll get your answers by the speed of light the next time you've got a question or problem:
    http://tkyte.blogspot.com/2005/06/how-to-ask-questions.html
    And don't refrain from using that tag ;)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Issue with a stored procedure that uses a sys refcursor to output dataset..

    Hi All:
    I create a stored procedure that uses an in out sys ref cursor:
    create or replace procedure FIRE_SALES_100_CALLS_REPORT
    ( p_cursor in out sys_refcursor)
    IS
    BEGIN
    --Insert into the temp table the records for the rep sales
    EXECUTE IMMEDIATE '
    INSERT INTO TMP_SALES_CNT_BY_USER
    TOTALPRODUCTSSOLD,
    NUMBEROFCALLS,
    SALESPER100CALLS,
    SERVICEORDERNUM,
    PRODUCT,
    LOGIN,
    FST_NAME,
    LAST_NAME,
    NAME,
    POSITIONHELD,
    CURRENTPARPARTYID,
    QUERY_DATE,
    CREATED_BY
    SELECT e.TotalProductsSold,
    e.NumberOfCalls,
    ((e.TotalProductsSold/e.NumberOfCalls)*100) AS SalesPer100Calls,
    e.ServiceOrderNum,
    e.Product,
    e.login,
    e.fst_name,
    e.last_name,
    e.name,
    e.PositionHeld,
    e.CurrentParPartyID,
    e.query_date,
    e.created_by
    FROM (
    SELECT COUNT(o.order_num) over ( partition by u.login
    order by u.login) AS TotalProductsSold,
    SUM(NVL(x.n_inbound,1) + NVL(x.n_outbound,1)) over (partition by u.login
    order by u.login) AS NumberOfCalls,
    o.order_num AS ServiceOrderNum,
    pi.name as Product,
    u.login,
    c.fst_name,
    c.last_name,
    postn.name,
    c.pr_held_postn_id as PositionHeld,
    p.par_party_id as CurrentParPartyID,
    NVL(x.query_date,NVL(o.last_upd, null)) AS query_date,
    o.created_by
    FROM firestg.SEB_S_order o
    INNER join firestg.seb_s_order_item oi ON o.row_id = oi.order_id
    INNER join firestg.seb_s_prod_int pi ON oi.prod_id = pi.row_id
    INNER join firestg.SEB_s_contact c on c.Row_Id = o.created_by
    INNER join firestg.SEB_s_user u on u.row_id = o.created_By
    INNER join firestg.SEB_s_party p on p.row_id = c.pr_held_postn_id
    INNER join firestg.SEB_s_postn postn on postn.row_id = c.pr_held_postn_id
    LEFT OUTER JOIN (
    SELECT taw.QUERY_DATE,
    vaw.n_inbound,
    vaw.n_outbound,
    oaw.object_name, oaw.object_id
    FROM GEN_T_AGENT_WEEK taw
    INNER JOIN GEN_V_AGENT_WEEK vaw ON taw.time_key = vaw.time_key
    INNER JOIN GEN_O_AGENT_WEEK oaw ON oaw.object_id = vaw.object_id) x
    ON u.cti_acd_userid = x.object_name
    WHERE NVL(x.query_date,NVL(o.last_upd, null)) BETWEEN (TRUNC (next_day (sysdate, ''SUN''))-14)
    AND (TRUNC (next_day (sysdate, ''SUN''))-8)
    AND o.status_cd IN (''Complete''))e';
    --Lookup the first level to see if there is a higher level person
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET (ParPartyID_1ST, LOGIN_1ST,FST_NAME_1ST,LST_NAME_1ST,TITLE_1ST) =
    (SELECT pa.par_party_id,
    U.Login,
    C.FST_NAME,
    C.Last_Name,
    p.name
    FROM firestg.seb_s_postn p
    inner join firestg.seb_s_user U on u.Row_Id = p.pr_emp_id
    inner join firestg.seb_s_contact c on c.Row_Id = p.pr_emp_id
    INNER join firestg.SEB_s_party pa on pa.row_id = c.pr_held_postn_id
    WHERE p.row_id = a.currentparpartyid)
    WHERE CurrentParPartyID IS NOT NULL';
    --Lookup the second level to see if there is a higher level person
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET (ParPartyID_2ND, LOGIN_2ND,FST_NAME_2ND,LST_NAME_2ND,TITLE_2ND) =
    (SELECT pa.par_party_id,
    U.Login,
    C.FST_NAME,
    C.Last_Name,
    p.name
    FROM firestg.seb_s_postn p
    inner join firestg.seb_s_user U on u.Row_Id = p.pr_emp_id
    inner join firestg.seb_s_contact c on c.Row_Id = p.pr_emp_id
    INNER join firestg.SEB_s_party pa on pa.row_id = c.pr_held_postn_id
    WHERE p.row_id = a.ParPartyID_1ST)
    WHERE a.ParPartyID_1ST IS NOT NULL';
    --Lookup the third level to see if there is a higher level person
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET (ParPartyID_3RD, LOGIN_3RD,FST_NAME_3RD,LST_NAME_3RD,TITLE_3RD) =
    (SELECT pa.par_party_id,
    U.Login,
    C.FST_NAME,
    C.Last_Name,
    p.name
    FROM firestg.seb_s_postn p
    inner join firestg.seb_s_user U on u.Row_Id = p.pr_emp_id
    inner join firestg.seb_s_contact c on c.Row_Id = p.pr_emp_id
    INNER join firestg.SEB_s_party pa on pa.row_id = c.pr_held_postn_id
    WHERE p.row_id = a.ParPartyID_2ND)
    WHERE a.ParPartyID_2ND IS NOT NULL';
    --Lookup the fourth level to see if there is a higher level person
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET (ParPartyID_4TH, LOGIN_4TH,FST_NAME_4TH,LST_NAME_4TH,TITLE_4TH) =
    (SELECT pa.par_party_id,
    U.Login,
    C.FST_NAME,
    C.Last_Name,
    p.name
    FROM firestg.seb_s_postn p
    inner join firestg.seb_s_user U on u.Row_Id = p.pr_emp_id
    inner join firestg.seb_s_contact c on c.Row_Id = p.pr_emp_id
    INNER join firestg.SEB_s_party pa on pa.row_id = c.pr_held_postn_id
    WHERE p.row_id = a.ParPartyID_3RD)
    WHERE a.ParPartyID_3RD IS NOT NULL';
    --Lookup the fifth level to see if there is a higher level person
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET (ParPartyID_5TH, LOGIN_5TH,FST_NAME_5TH,LST_NAME_5TH,TITLE_5TH) =
    (SELECT pa.par_party_id,
    U.Login,
    C.FST_NAME,
    C.Last_Name,
    p.name
    FROM firestg.seb_s_postn p
    inner join firestg.seb_s_user U on u.Row_Id = p.pr_emp_id
    inner join firestg.seb_s_contact c on c.Row_Id = p.pr_emp_id
    INNER join firestg.SEB_s_party pa on pa.row_id = c.pr_held_postn_id
    WHERE p.row_id = a.ParPartyID_4TH)
    WHERE a.ParPartyID_4TH IS NOT NULL';
    -- If there was no 1st place then the rep is a VP
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET a.vp = a.last_name || '', '' || a.fst_name,
    a.vp_login = a.login
    WHERE a.login_1st IS NULL';
    --If there is no second place then the rep has a VP and is a Director
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET a.vp = a.lst_name_1st || '', '' || a.fst_name_1st,
    a.vp_login = a.login_1st,
    a.director = a.last_name || '', '' || a.fst_name,
    a.director_login = a.login
    WHERE a.login_1st IS NOT NULL
    AND a.login_2ND IS NULL';
    --IF there is no third place then the rep has a VP, Director & is a Manager
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET a.vp = a.lst_name_2ND || '', '' || a.fst_name_2ND,
    a.vp_login = a.login_2ND,
    a.director = a.lst_name_1st || '', '' || a.fst_name_1st,
    a.director_login = a.login_1st,
    a.manager = a.last_name || '', '' || a.fst_name,
    a.manager_login = a.login
    WHERE a.login_1st IS NOT NULL
    AND a.login_2ND IS NOT NULL
    AND a.login_3rd IS NULL';
    --If there is no fourth place then the rep has a VP, Dir, Manager, and is a Supervisor
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET a.vp = a.lst_name_3RD || '', '' || a.fst_name_3RD,
    a.vp_login = a.login_3RD,
    a.director = a.lst_name_2ND || '', '' || a.fst_name_2ND,
    a.director_login = a.login_2ND,
    a.manager = a.lst_name_1st || '', '' || a.fst_name_1st,
    a.manager_login = a.login_1st,
    a.supervisor = a.last_name || '', '' || a.fst_name,
    a.supervisor_login = a.login
    WHERE a.login_1st IS NOT NULL
    AND a.login_2ND IS NOT NULL
    AND a.login_3rd IS NOT NULL
    AND a.login_4th IS NULL';
    --If there is no fifth plance then the rep has a VP, Dir, Mgr, Supervisor, and is a Team Lead
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET a.vp = a.lst_name_4TH || '', '' || a.fst_name_4TH,
    a.vp_login = a.login_4TH,
    a.director = a.lst_name_3RD || '', '' || a.fst_name_3RD,
    a.director_login = a.login_3RD,
    a.manager = a.lst_name_2ND || '', '' || a.fst_name_2ND,
    a.manager_login = a.login_2ND,
    a.supervisor = a.lst_name_1st || '', '' || a.fst_name_1st,
    a.supervisor_login = a.login_1st,
    a.teamlead = a.last_name || '', '' || a.fst_name,
    a.teamlead_login = a.login
    WHERE a.login_1st IS NOT NULL
    AND a.login_2ND IS NOT NULL
    AND a.login_3rd IS NOT NULL
    AND a.login_4th IS NOT NULL
    AND a.login_5th IS NULL';
    --If there is a fifth place then the rep has a VP, Dir, Mgr, Supervisor, Team Lead and is a rep
    EXECUTE IMMEDIATE '
    UPDATE TMP_SALES_CNT_BY_USER a
    SET a.vp = a.lst_name_5TH || '', '' || a.fst_name_5TH,
    a.vp_login = a.login_5TH,
    a.director = a.lst_name_4TH || '', '' || a.fst_name_4TH,
    a.director_login = a.login_4TH,
    a.manager = a.lst_name_3RD || '', '' || a.fst_name_3RD,
    a.manager_login = a.login_3RD,
    a.supervisor = a.lst_name_2ND || '', '' || a.fst_name_2ND,
    a.supervisor_login = a.login_2ND,
    a.teamlead = a.lst_name_1st || '', '' || a.fst_name_1st,
    a.teamlead_login = a.login_1st
    WHERE a.login_1st IS NOT NULL
    AND a.login_2ND IS NOT NULL
    AND a.login_3rd IS NOT NULL
    AND a.login_4th IS NOT NULL
    AND a.login_5th IS NOT NULL';
    open p_cursor for
    SELECT tsc.vp,
    tsc.director,
    tsc.manager,
    tsc.supervisor,
    tsc.teamlead,
    (tsc.last_name || ', ' || tsc.fst_name) AS Rep,
    tsc.product,
    tsc.totalproductssold,
    tsc.numberofcalls,
    tsc.salesper100calls
    FROM TMP_SALES_CNT_BY_USER tsc;
    END FIRE_SALES_100_CALLS_REPORT;
    The table I use is a Global temp table.
    This runs just fine in oracle but when I try to build a data foundation in Business Objects I get the error that says you cannot insert/update/delete in a READ ONLY Transaction.
    I really need some advice on what to do since I really dont have access to a scheduled script and table that would store my data ahead of time.

    Well, AFAIK, BO is a reporting tool, so it si read-only by nature. I do not know if it possible to "tell" BO table is GTT and it is OK to write to it. You need to post this in BO forum.
    SY.

  • Issue with sys_refcursor  in oracle  10.2.0.4.0

    hi,
    java is front end application and they want result set to be returned from oracle plsql, for simplicity i am writing code something like below.
    create or replace function fun () retrun sys_refcursor is
    tablename_cur sys_Refcursor;
    begin
    open tablename_cur for select statement;
    return tablename_cur ;
    end;
    its all looks good.. but my client IT person questioned me about not closing cursor..
    i feel it is good way of doing, not closing this type of cursor variable is fine i.e. tablename_cur in this case, does it cause any issues otherwise.. since i am about write not less 300+ such functions and would like to know on this if this is right practice or would it cuase any increase of opened cursor and never closed,.... therafter any performance issues..
    or any other good practive to perform the same task. .. please suggest..
    thanks in advance...

    knowledgespring wrote:
    I assume once sys_Refcursor returned all the rows it get closed automatically... i.e. fetched all the rows from it closes the sys_refcursor.. otherwise provide info.
    according to you, does it mean if they close result set they use in java would result close of sys_refcursor!!.. not before.. may be somthing like
    ResultSet rs = call oracle function which uses sys_refcursor
    rs.close --> does it close sys_refcursor .. (would it open till then??!!!)..
    java developers says we call functions written in oracle... and resultset to be returned.. (They are different team)..I don't know java, but it's correct, the consumer of the cursor is responsible for closing it.
    e.g.
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace function test_rc return sys_refcursor is
      2    v_rc sys_refcursor;
      3  begin
      4    open v_rc for 'select * from emp';
      5    return v_rc;
      6* end;
    SQL> /
    Function created.
    SQL> var x refcursor;
    SQL> exec :x := test_rc();
    PL/SQL procedure successfully completed.
    SQL> print x;
         EMPNO ENAME      JOB              MGR HIREDATE          SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17/12/1980        800                    20
          7499 ALLEN      SALESMAN        7698 20/02/1981       1600        300         30
          7521 WARD       SALESMAN        7698 22/02/1981       1250        500         30
          7566 JONES      MANAGER         7839 02/04/1981       2975                    20
          7654 MARTIN     SALESMAN        7698 28/09/1981       1250       1400         30
          7698 BLAKE      MANAGER         7839 01/05/1981       2850                    30
          7782 CLARK      MANAGER         7839 09/06/1981       2450                    10
          7788 SCOTT      ANALYST         7566 19/04/1987       3000                    20
          7839 KING       PRESIDENT            17/11/1981       5000                    10
          7844 TURNER     SALESMAN        7698 08/09/1981       1500          0         30
          7876 ADAMS      CLERK           7788 23/05/1987       1100                    20
          7900 JAMES      CLERK           7698 03/12/1981        950                    30
          7902 FORD       ANALYST         7566 03/12/1981       3000                    20
          7934 MILLER     CLERK           7782 23/01/1982       1300                    10
    14 rows selected.Here, the "print" command of SQL*Plus uses the returned ref cursor to fetch the data back from the database, and when it's done it (behind the scenes) closes the cursor.
    Oracle can't keep track (or even possibly know) of whether a client consumer of a ref cursor has finished fetching the records. Just because all the records may have been fetched, the cursor itself remains open until closed as it contains information about the state of the cursor e.g. whether there is more data to fetch or not.
    {thread:id=886365}

  • Dynamic Column Names using Refcursors

    Hi,
    I have a stored procedure which returns a refcursor. The refcursor contains a SQL query in which the column names and number of columns vary dynamically based on the date parameters passed.
    "My objective is to return certain XYZ details of employees for a certain month range."
    For ex: For the month of Aug-2011, the column names would be '1-AUG-11' to '31-AUG-11 and for Feb-2011 '1-FEB-11' to '28-FEB-11'
    My issue is, when I execute the refcursor query using "EXEC", my column names/headings are preserved.
    FIELD NAMES: EMPLOYEE_CODE XYZ_TYPE *1-AUG-11* *2-AUG-11* ... *31-AUG-11*
    DATA: EMPCODE_Z TYPE1 VALUE_1 VALUE_1 ... VALUE_31
    Whereas when I fetch the refcursor into a collection of nested table and display, my column names are lost.
    DATA: EMPCODE_Z TYPE1 VALUE_1 VALUE_1 ... VALUE_31
    Is there a way where I can preserve the column names from the refcursor after fetching into pl/sql collections?
    Any help would be highly appreciated.
    Thank you.
    Edited by: 867622 on Nov 11, 2011 4:38 PM

    867622 wrote:
    If not dynamic SQL, how can the number of columns be altered based on the input parameters?Cannot. A dynamic SQL projection means dynamic SQL (there's an exception to this, and despite interesting is not relevant to 99.99% of problems dealing with dynamic SQL projections).
    You can however still use a dynamic projection and wrap that into a user defined type interface.
    Here's the basic approach:
    // create a user define type that will provide the wrapper for the SQL projection
    create or replace type TString as table of varchar2(4000);
    // build dynamic SQL projections via this type, e.g.
    select
      TStrings( object_id, object_name, created )
    from user_objects
    select
      TStrings( emp_id, dept_id, salary, commission )
    from employeesDespite the SQL cursors being different and the columns and number of columns being selected different, the SQL projection of both are the same. The Count method tells you the number of columns in the projection. Referencing an applicable column is simply done by using the column's sequential number in the projection.
    You also do not have to use a collection or varchar2 as the wrapper type - you can create complex user objects and use the collection type for that, as the SQL projection.
    Another alternative is converting the ref cursor into a DBMS_SQL cursor and using the latter's describe interface to dynamically determine the structure of the SQL projection and fetching the column values from it. But 11gr1 or later is needed for doing this.

  • REFCURSOR in getCursor CallableStatement

    Hi ,
    I am calling a stored package procedure which returns REFCursor (i am using oracle 8.1.6 as backend) throughjdbc
    am importing the Oracle JDBC drivers which support bind variables of type REFCURSOR.(classes from the oracle.jdbc.driver package
    8.1.7 driver)
    Used the getCursor method of the CallableStatement to convert a REFCURSOR value returned by a PL/SQL block
    into a ResultSet.
    Casting the corresponding CallableStatement to oracle.jdbc.driver.OracleCallableStatement to use the getCursor method.
    The problem is this works absolutely fine if i connect as the owner of the package procedure. but if i create a public syonym for the same package and grant execute
    on package to other user.
    And now if i connect as this other user through jdbc and run the same program it gives me SQLException
    ora-00942 table or view does not exit.
    (and the same thing works fine from sql*plus when the package is tested from thsi other) just to inform you that no grants / rights issues over here.
    I am just unable to understand how do i proceed in this case, as no way i can have the package procedure being created in the same user, also doesn't sound
    implementable in live environment.
    Can any body confirm, if this is a bug in the dirver am using, and if so where do i find this
    Please help me.
    I hope i have given required info to get an answer.
    Thanks. Geeta
    null

    I had the same problem. It only worked
    for me if I granted both execute
    permission on the Package as well as
    select permission on the table accessed
    by the package (which doesn't make sense)
    null

  • Refcursor taking a lot of time to print results

    Hi Gurus,
    I have a table with name kemp with columns
    kemp_ID NOT NULL NUMBER(10)
    ACRONYM CLOB
    TERM CLOB
    DEFINITION CLOB When I do a query on table
    select * from kemp ; results are getting displayed very soon lesser than *1.5 seconds* But when I write a procedure to return the results using refcursor
    create procedure pr_retall(cv_1 in out sys_refcursor)
    as
    begin
    open cv_1 for select * from kemp ;
    end;
    set serveroutput on size unlimited;
    var x1 refcursor;
    exec pr_retall(:x1);
    print x1;This is taking around *7 seconds* for getting displayed.
    Please tell me know ways to tune it. I want to reduce the time it is consuming.
    Thanks & Regards,
    Vikas Krishna

    Vikas Krishna wrote:
    Please find the timing.
    <snipped>Using elapsed time (as you did) to measure and benchmark performance is wrong.
    Why? Because the test2 is seldom, if ever given how these tests are usually done, executed using the very same conditions that test1 was executed in.
    As conditions differ between tests, elapsed time differs. As conditions differ, you cannot compare test1 with test2. I gave an example of how wrong this is in thread {message:id=4333700} - where physical I/O slows down test1 and logical I/O speeds up test2. And how this can be used to substantiate the erroneous conclusion that the non-existing CBO hint warp_drive increased the performance of test2.
    If you want to benchmark test1 against test2, you need to know in exact detail how each test technically works.. need to know how to ensure that the commonality between the two tests remain constant for all tests and how to measure only those parts that are different between tests.
    And no, benchmarking is not that complex. It is in fact even more complex than this. Which is why it is best left to those who know how to benchmark.. on behalf of those that can find some meaning in the result of that benchmark.
    For the majority of us working and developing in the real world, benchmarking is achieving a useless answer to a meaningless question for a nonsensical issue. Utterly useless...

  • Opening refcursor for every loop value

    Guys,
    I have a refcursor which is getting opened for different values which is coming from the enclosing loops but while executing the refcursor is getting fired for once .Please let me know if there is any caveats.
    Here is the code pasted
    declare
    cursor cur_col_dtls is select column_name FROM user_tab_columns WHERE table_name ='JOURNAL_DATA' AND column_name LIKE UPPER('field_def_id%')
    ORDER BY SUBSTR(column_name,-3);
    v_commit_point number :=0;
    type ref_cur IS ref CURSOR;
    v_ref_cur ref_cur;
    v_slct VARCHAR2(4000);
    v_col_no NUMBER;
    v_data tj_data_pivot%ROWTYPE;
    BEGIN
    FOR v_dtls IN cur_col_dtls LOOP
    IF length(v_dtls.column_name)=16 THEN
    v_col_no :=SUBSTR(v_dtls.column_name,-3);
    ELSIF length(v_dtls.column_name)=15 THEN
    v_col_no :=SUBSTR(v_dtls.column_name,-2);
    ELSE
    v_col_no :=SUBSTR(v_dtls.column_name,-1);
    END IF;
    v_slct :='select journal_entry_id, partition_date,'|| v_col_no||',field_def_id_'||v_col_no||', value_'||v_col_no||' from tp.journal_data where field_def_id_'||v_col_no||' is not null and journal_entry_id>(select NVL(max(journal_entry_id),0) from tj_data_pivot)';
    -- DBMS_OUTPUT.PUT_LINE (v_dtls.column_name|| ' '||v_col_no||' '||v_slct);
    IF v_ref_cur%ISOPEN THEN
    close v_ref_cur;
    END IF;
    OPEN v_ref_cur FOR v_slct ;
    <<innerloop>>
    LOOP
    FETCH v_ref_cur INTO v_data;
    --dbms_output.put_line (v_slct);
    EXIT innerloop WHEN v_ref_cur%NOTFOUND;
    INSERT INTO TEST VALUES(v_data.journal_entry_id);
    -- DBMS_OUTPUT.PUT_LINE (v_data.journal_entry_id||','||v_data.partition_date||','||v_data.field_value);
    --INSERT INTO tj_data_pivot VALUES (v_data.journal_entry_id,v_data.partition_date,v_data.field_seq,v_data.field_def,v_data.field_value);
    v_commit_point :=v_commit_point+1;
    IF v_commit_point=1000 THEN
    COMMIT;
    v_commit_point :=0;
    END IF;
    END LOOP innerloop;
    -- close v_ref_cur;
    -- exit when v_col_no=1;
    END LOOP;
    -- v_slct :='select journal_entry_id, partition_date, 1, field_def_id_1, value_1 from tp.journal_data where field_def_id_1 is not null
    END;

    Congratulations!!
    This is an excellent example of how PL/SQL can be abused.
    Apart from that your 'code' will turn Oracle from a Ferrari into a T-Ford (black).
    Your code doesn't scale as it uses dynamic sql.
    You commit one of the gravest sins in Oracle: you commit inside a loop.
    You don't use BULK COLLECT.
    But more importantly: your data model is an utter complete mess, as it doesn't even adhere to First Normal Form, as it has repeating groups.
    There is only one advice possible: before you do continue,
    issue the
    drop database
    command.
    Then issue the
    Drop brain prafullu
    command.
    Then start learning databases, unlearning all of the evil practises you've 'learned' so far.
    Sybrand Bakker
    Senior Oracle DBA

  • Refcursor IN

    Hello All,
    I'm using oracle 11gR2
    One of our user wants all their LOVs maintained thru a UI. They have close to 50 LOV tables with no. of fields ranging from 5 to 10 with mostly different names.
    I'm trying to write a generalized package to get the values, set the values and delete the values. We have permissions/privileges being checked before any of the DML being performed.
    for the get procedure, I'm returning a refcursor when they pass in the table name (may not be ideal but....had to) and now starting to work on the set procedure (insert new values). Some of the issues that I'm trying to address is that the number of fields are not constant, the field names are different etc..
    Would passing in a refursor work for this scenario? or is there better ways of doing it? Please shed some light.
    Thanks in advance
    NU

    >
    One of our user wants all their LOVs maintained thru a UI. They have close to 50 LOV tables with no. of fields ranging from 5 to 10 with mostly different names.
    I'm trying to write a generalized package to get the values, set the values and delete the values. We have permissions/privileges being checked before any of the DML being performed.
    Some of the issues that I'm trying to address is that the number of fields are not constant, the field names are different
    >
    First you need to quit focusing on the solution you seem to want to use (ref cursor) and get back to focusing on defining the problem and the requirements.
    Once the complete requirements are available you can start looking for solutions that can be used.
    >
    I'm trying to write a generalized package
    >
    Well you can't do that if the requirements (column names and number of columns) for the 50 LOVs are different.
    You either have to make the number and names of columns the same (using a view perhaps) or you will need more than one 'generic' set of code (that is, one for each set of LOVs that is consistent.
    What UI are you talking about? A Java middle-tier? You may have a choice of where to put the business rules: in the middle tier so the back-end code is more generic or in the back-end.
    I suggest you first need to review the 50 LOVs and determine how many similar sets of them that you have.
    Some common attirbutes might be: 1) actual attribute name, 2) display name, 3) actual attribute value, 4) display value/format
    The 'display' attributes are what the business user wants displayed and the name they want to use to refer to the attribute ('State Code'). The 'actual' attributes are what is really used in the back-end ('STATE_CD'). For generics you want to use a mapping table so you can map the business name to the actual name and break the dependency.
    The key thing is what I said above. Focus on nailing down the requirements. The correct solution will be more readily apparent when you know for sure what all of the issues are.

  • Disadvantages of using REFCURSORs from JDBC

    Hi,
    Normally I write my SQL statements from inside Java (eg PreparedStatements).
    I am investigating on creating PL/SQL Packages, supplying procedures and methods, which I can call from Java using CallableStatements. I understand the advantages of having a layer/API on the database side.
    For example: retrieve some records from a table. (the PL/SQL function getCustomers returns a REFCURSOR)
    - PreparedStatement (select ... from ... where ...) -> executeQuery -> loop ResultSet
    - CallableStatement ("begin ? := getCustomers(); end;") -> cast getObject() to ResultSet -> loop ResultSet
    What are the disadvantages of using the CallableStatement (REFCURSOR)?
    Thanks, regards, Stephan

    While that article may be a good intro for someone not familiar with JDBC it has some misinformation in it that can be misleading at best and cause performance and memory issues at worst.
    Row-prefetching - there is little benefit to using a large value for this setting. As with most things extremes are to be avoided.
    It is important to know how the data is going to be used. What is the point of bringing ALL the data from the DB in one call if you are going to write it to the file system. File I/O is generally the slowest part of an application.
    It is also important that the code be scaleable. Apps should be written so that future modifications will impact existing functionality as little as possible. If you eat up the memory for one table or statement that limits the memory available for other uses. Worse, when things go wrong and you need to reduce the fetch setting you may now have problems everywhere because the testing you originally performed may have relied on that larger fetch setting.
    If the data fetching is not done in its own thread then using a very large value can actually make an application appear to 'freeze' while it waits for the data fetch to complete.
    A large fetch size can also waste significant amounts of memory; essentially allocating it but never using it and never allowing any other process to use it. This is because for a fetch size of 'n' Oracle has to allocate space for 'n' rows that are each of maximum size.
    This wasted is most often due to the common VARCHAR2 datatype. Consider a single column defined as VARCHAR2(100). In the DB this column is stored as variable length. But Oracle will allocate 100 characters (could be multi-byte characters) in order to be able to hold a maximum length value.
    If the actual data values never exceed 30 bytes then 70 bytes in each row are totally wasted. The more rows that are prefetched the more memory that is wasted simply in anticipation of a maximum length value that never occurs or only occurs rarely.
    I've never used a prefetch/fetch size greater than one thousand and that was for tables with small records (no more than 10 or 20 columns).
    And the Oracle docs don't even recommend a setting that high. See the JDBC Dev Guide
    http://docs.oracle.com/cd/B19306_01/java.102/b14355/oraperf.htm#i1043756
    >
    Oracle Row-Prefetching Limitations
    There is no maximum prefetch setting, but empirical evidence suggests that 10 is effective. Oracle has never observed a performance benefit to setting prefetch higher than 50. If you do not set the default row-prefetch value for a connection, then 10 is the default.

  • Refcursor related prob

    i have a simple query it is working from sqlplus bt it is not working from refcursor.
    what should be the issue.
    (using refcursor) it does not return any row,

    v_cur_sql :=
    'select UNIV_FILE_NAME,NE_ID_KEY,SERVED_MSRN,OTHER_MSISDN,
                        CALL_START_TIME_SLOT_KEY,
                        CAUSE_OF_TERMINATION,
                        CHARGE,CDR_SEQ_NUM,SERVED_MSISDN,REC_TYPE_KEY,
                        EVENT_TYPE_KEY,CALL_DIRECTION_KEY,CHRG_UNIT_ID_KEY,
                        DIAL_DIGIT_KEY,CALL_START_TIME,OUT_TG_ID_KEY,IN_TG_ID_KEY,
                        NULL,NULL,NULL,NULL,CALL_END_TIME FROM '
                        || p_cn_tab || ' WHERE ' || v_filter ||
         ' AND CALL_START_TIME between TO_DATE(''' || p_startDate ||''',''mm/dd/yyyy hh24:mi:ss'') AND TO_DATE('''|| p_endDate || ''',''mm/dd/yyyy hh24:mi:ss'') '
              ||' AND IS_RATED IS NULL';
    FETCH C_REF_CUR
    INTO
              <------>
    it return 0 rows.

  • Calling a storedprocedure returning refcursor of xmltype

    Hi,
    I'm having issues with stored procedure, returning a refcursor of xmltypes. Most of the examples in the docs(http://docs.oracle.com/html/E10927_01/featXML.htm#i1012109) are always a direct query and I have yet to see one using a stored procedure.
    Here's a repro script:
    Register an xsd:
    BEGIN
    dbms_xmlschema.registerschema('http://www.testing.com/person.xsd',
    '<?xml version = "1.0" encoding = "utf-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      elementFormDefault="qualified" attributeFormDefault="unqualified">
      <xs:element name="person">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="first_name" type="xs:string"/>
            <xs:element name="last_name" type="xs:string"/>
            <xs:element name="gender">
              <xs:simpleType>
                <xs:restriction base="xs:string">
                  <xs:enumeration value="male"/>
                  <xs:enumeration value="female"/>
                </xs:restriction>
              </xs:simpleType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>',
    LOCAL => FALSE, -- local
    GENTYPES => FALSE, -- generate object types
    GENBEAN => FALSE, -- no java beans
    GENTABLES => TRUE, -- generate object tables
    FORCE => FALSE,
    options => dbms_xmlschema.register_binaryxml,
    OWNER => USER );
    END;
    --create a array of int type
    CREATE OR REPLACE
    type int_array_type as table of number;
    -- Create the table
    CREATE TABLE person
        ID NUMBER,
        xml_document XMLTYPE
      xmltype column xml_document STORE AS BINARY XML XMLSCHEMA "http://www.testing.com/person.xsd" element "person";
    -- insert some data
    INSERT INTO person (ID, xml_document)
    VALUES (1, XMLTYPE ('<?xml version="1.0" encoding="utf-8"?>
    <person xsi:noNamespaceSchemaLocation="http://www.testing.com/person.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <first_name>John</first_name>
      <last_name>Doe</last_name>
      <gender>male</gender>
    </person>'));
    INSERT INTO person (ID, xml_document)
    VALUES (2, XMLTYPE ('<?xml version="1.0" encoding="utf-8"?>
    <person xsi:noNamespaceSchemaLocation="http://www.testing.com/person.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <first_name>Jane</first_name>
      <last_name>Doe</last_name>
      <gender>female</gender>
    </person>'));
    Create the Package
    create or replace
    package test_pkg as
      TYPE refcursor IS REF CURSOR;
      type t_id_array is table of number index by binary_integer;
        -- user procs
      procedure udp_get_personlist (
          p_ids IN t_id_array,
          p_resultset out refcursor );
    end test_pkg;
    create or replace
    package body test_pkg as
      procedure udp_get_personlist (
          p_ids IN t_id_array,
          p_resultset out refcursor ) IS
          v_int_array_type int_array_type := int_array_type();
      begin
         FOR i IN 1..p_ids.COUNT LOOP
          v_int_array_type.extend(1);
          v_int_array_type(i) := p_ids(i);     
        END LOOP;   
        OPEN p_resultset FOR
        SELECT E.XML_DOCUMENT AS "person" FROM person E
        WHERE e.ID IN ( SELECT t.COLUMN_VALUE FROM TABLE ( v_int_array_type ) t );
      end udp_get_personlist;
    end test_pkg;And here is my ODP.NET code
    using (var con = new OracleConnection("<your oracle connection>"))
         using (var cmd = con.CreateCommand())
              cmd.CommandText = "test_pkg.udp_get_personlist";
              cmd.CommandType = CommandType.StoredProcedure;
              int[] ids = new int[] { 1, 2 };
              OracleParameter param1 = cmd.Parameters.Add("p_ids", OracleDbType.Int32);
              OracleParameter param2 = cmd.Parameters.Add("p_resultset", OracleDbType.RefCursor, ParameterDirection.Output);
              param1.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
              param1.Value = ids;
              param1.Size = ids.Length;
              param1.ArrayBindSize = new int[] { 4, 4 };
              // Setup the ArrayBind Status for param2
              param1.ArrayBindStatus = new OracleParameterStatus[1] { OracleParameterStatus.Success }; //, OracleParameterStatus.Success };
              try
                   cmd.XmlQueryProperties.MaxRows = 1;
                   con.Open();
                   XmlReader r = cmd.ExecuteXmlReader(); // this always generates invalidoperationexception
                   // do something with the result
              catch (Exception)
                   throw;
              // Close and Dispose OracleConnection object
              con.Close();
              con.Dispose();
    }     Server/Tools information:
    Oracle is Standard - Oracle Database 11g Release 11.2.0.1.0 running on Windows Server 2003 Std
    ODP.NET (ie Oracle.DataAccess.DLL is 4.112.3.0);
    Visual Studio 2010 Ultimate SP1
    Any pointers in what I'm (obviously doing wrong) is greatly appreciated...
    thanks
    Edited by: 947266 on Sep 10, 2012 9:46 AM

    Was able to make it work
    using (var con = new OracleConnection("<your oracle connection>"))
         using (var cmd = con.CreateCommand())
              cmd.CommandText = "test_pkg.udp_get_personlist";
              cmd.CommandType = CommandType.StoredProcedure;
              int[] ids = new int[] { 1, 2 };
              OracleParameter param1 = cmd.Parameters.Add("p_ids", OracleDbType.Int32);
              OracleParameter param2 = cmd.Parameters.Add("p_resultset", OracleDbType.RefCursor, ParameterDirection.Output);
              param1.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
              param1.Value = ids;
              param1.Size = ids.Length;
              param1.ArrayBindSize = new int[] { 4, 4 };
              // Setup the ArrayBind Status for param2
              param1.ArrayBindStatus = new OracleParameterStatus[1] { OracleParameterStatus.Success }; //, OracleParameterStatus.Success };
              try
                   cmd.XmlQueryProperties.MaxRows = 1;
                   con.Open();
                   int i = cmd.ExecuteNonQuery();
                            OracleRefCursor curs = (OracleRefCursor)cmd.Parameters["p_resultset"].Value;
                            OracleDataReader dr = curs.GetDataReader();
                            while (dr.Read())
                                Console.WriteLine(dr[0].ToString()); 
              catch (Exception)
                   throw;
              // Close and Dispose OracleConnection object
              con.Close();
              con.Dispose();
    }

Maybe you are looking for