OUT parameter with NOCOPY hint of type SYS_REFCURSOR

Hi,
I am having a procedure which returns a set of 100+ records (each record having 10+ columns) through a OUT parameter of type SYS_REFCURSOR.
These output records are used in JAVA code for fecthing the resultset and process data.
Will it make any difference in performance if I use NOPCOPY compiler hint in this procedure (especially I am interested in the interaction between JAVA and PLSQL, with and without NOCOPY parameter).
Thanks.
Edited by: user2946813 on Mar 25, 2012 9:15 PM

user2946813 wrote:
Hi RP,
Thanks for the answer.
So the PLSQL OUT parameter of type SYS_REFCURSOR would be passing just a reference (memory address) to JAVA.
This behavior is same with or without NOCOPY. Is my understanding correct?
Thanks.Yes. A ref cursor is just a pointer to a query, not a result set of data. Using NOCOPY or not is pointless (excuse the pun) because, no matter how much data is going to get returned, the pointer itself is no smaller or larger in size, and thus using NOCOPY won't improve performance or save resources.
{thread:id=886365}

Similar Messages

  • Cursor bound to out parameter with Connection Pool

    Is it possible to retrieve a cursor bound to an out parameter when using the thin
    driver to establish the connection pool to the database? I am currently using
    the JDriver to connect create the pool and the pool driver to connect from the
    app to the connection pool. We'd like to avoid using the Oracle client if possible.
    Currently I register the out parameter as java.sql.Types.OTHER, then call getResultSet(1)
    on the weblogic.jdbc.pool.CallableStatement object. But it breaks when I change
    the connection pool to use the thin driver. The error is at the bottom of this
    post.
    I think I could possibly get the current pool driver to work if can find some
    documentation on these two methods:
    void registerOutParameter(int i, int j, int k, int l)
    void registerOutParameter(int i, int sqlType, java.lang.String typeName)
    I have no idea what to put in for the ints in the first method or for sqlType
    or typeName. Can anyone point me to where I can find this documentation?
    E-docs mentions this class: weblogic.jdbc.vendor.oracle.OracleCallableStatement.
    (http://edocs.bea.com/wls/docs61/jdbc/thirdparty.html#1023867). Should I consider
    this? If so where is it?
    Thanks a lot,
    Matt Savino
    <<< error when using thin driver >>>
    preparing callable stmt
    callable stmt prepared, java.sql.Types.OTHER = 1111
    java.sql.SQLException: Invalid column type
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:273)
    at oracle.jdbc.driver.OracleStatement.get_internal_type(OracleStatement.java:4560)
    at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:225)
    at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:350)
    at weblogic.jdbc.pool.Statement.registerOutParameter(Statement.java:617)
    at jsp_servlet._reportmanager.__thin_outputresultset._jspService(__thin_outputresultset.java:145)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:263)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:200)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:2390)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:1959)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)

    Thanks Joe, your answer pointed me in the right direction. Just in case anyone
    wants to know, the solution took two changes:
    CHANGE
    cStat.registerOutParameter(1, java.sql.Types.OTHER);
    TO
    cStat.registerOutParameter(1, oracle.jdbc.driver.OracleTypes.CURSOR);
    (cStat is an instance of weblogic.jdbc.pool.CallableStatement)
    AND
    rs = cStat.getResultSet(1);
    TO
    rs = cStat.getCursor(1);
    Thanks again,
    Matt
    Joseph Weinstein <[email protected]> wrote:
    Hi Matt.
    Look at the Oracle thin driver documentation to determine what type you
    should define in the registerOutParameter call. We use 'OTHER', but
    their driver may use something else for CURSOR output parameters.
    joe
    Matt Savino wrote:
    Is it possible to retrieve a cursor bound to an out parameter whenusing the thin
    driver to establish the connection pool to the database? I am currentlyusing
    the JDriver to connect create the pool and the pool driver to connectfrom the
    app to the connection pool. We'd like to avoid using the Oracle clientif possible.
    Currently I register the out parameter as java.sql.Types.OTHER, thencall getResultSet(1)
    on the weblogic.jdbc.pool.CallableStatement object. But it breaks whenI change
    the connection pool to use the thin driver. The error is at the bottomof this
    post.
    I think I could possibly get the current pool driver to work if canfind some
    documentation on these two methods:
    void registerOutParameter(int i, int j, int k, int l)
    void registerOutParameter(int i, int sqlType, java.lang.String typeName)
    I have no idea what to put in for the ints in the first method or forsqlType
    or typeName. Can anyone point me to where I can find this documentation?
    E-docs mentions this class: weblogic.jdbc.vendor.oracle.OracleCallableStatement.
    (http://edocs.bea.com/wls/docs61/jdbc/thirdparty.html#1023867). Should
    I consider
    this? If so where is it?
    Thanks a lot,
    Matt Savino
    <<< error when using thin driver >>>
    preparing callable stmt
    callable stmt prepared, java.sql.Types.OTHER = 1111
    java.sql.SQLException: Invalid column type
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:273)
    at oracle.jdbc.driver.OracleStatement.get_internal_type(OracleStatement.java:4560)
    at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:225)
    at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:350)
    at weblogic.jdbc.pool.Statement.registerOutParameter(Statement.java:617)
    at jsp_servlet._reportmanager.__thin_outputresultset._jspService(__thin_outputresultset.java:145)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:263)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:200)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:2390)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:1959)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    PS: Folks: BEA WebLogic is expanding rapidly, with both entry and advanced
    positions
    for people who want to work with Java, XML, SOAP and E-Commerce infrastructure
    products.
    We have jobs at Nashua NH, Liberty Corner NJ, San Francisco and San Jose
    CA.
    Send resumes to [email protected]

  • Stored Procedure with in out parameter of table of records type

    Hi
    I am tring to create a strore procedure inside a package like this:
    procedure name_p(root in table.column%type, tab in out table_of_records_type);
    I get the error:
    PLS-00306: Wrong number or types of arguments in call to 'name_p'
    I am working with oracle 8.1.7.
    I dont really understand why this is happening.
    Can anyone suggest anything.
    Thnx
    Ed

    An example :
    TEST@db102 SQL> select ename, job from emp
      2  where empno = 7902;
    ENAME      JOB
    FORD       ANALYST
    TEST@db102 SQL> create or replace procedure show_emp (
      2     v_empno in      number,
      3     v_ename out     varchar2,
      4     v_job   out     varchar2 )
      5  is
      6  begin
      7     select ename, job into v_ename, v_job
      8     from emp
      9     where empno = v_empno;
    10  end;
    TEST@db102 SQL> /
    Procedure created.
    TEST@db102 SQL> exit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    [ora102 work db102]$ IN=7902
    [ora102 work db102]$ set `sqlplus -s test/test@db102 << !
    var out1 varchar2(30);
    var out2 varchar2(30);
    set pages 0
    set feed off
    exec show_emp($IN,:out1,:out2);
    print
    exit
    `[ora102 work db102]$ echo $1 $2
    FORD ANALYST
    [ora102 work db102]$                           

  • Proble with out parameter

    Dear all i am facing a Problem in oracle 10 g while calling a procedure. this procedure has one 'IN' and three 'Out' parameter( one out parameter is refcursor)
    this procedure run successfully and has no complier error. but does not return any value
    but if i remove one out parameter ie (total two with one ref cursor )it works perfectly and returns value )
    so please any one can tell me is there any limit of using out parameter with ref cursor as out parameter

    Dear arun here is the code
    PROCEDURE Sp_Report_Manager(MODULEID IN VARCHAR,
    FROM_DATE IN DATE,
    TO_DATE IN DATE,
    P_ERROROCCURRED OUT NUMBER,
    COLUMN_NAMES OUT VARCHAR,
    REC_DEALDATA OUT Globrefcursor.gref)
    IS
    LV_SQL VARCHAR2(4000);
    LV_GRID_SQL VARCHAR2(4000);
    BEGIN
    p_debug('a','1');
    P_ERROROCCURRED:=0;
    p_debug('a','2');
    IF MODULEID IS NOT NULL THEN
    BEGIN
    p_debug('a','3');
    COLUMN_NAMES:='SELECTED,CPARTY,DEAL_ID,SCHEME,TRAN_TYPE,ASSET_TYPE,ASSET_GROUP,VALUE_DATE^Select,Deal ID,Scheme,Tran Type,Asset Type,Asset Group,Trade Date';
    LV_SQL := 'SELECT GRID_SQL FROM DEA_REPORT_MANAGER WHERE MODULE = :1';
    p_debug('a','4');
         EXECUTE IMMEDIATE LV_SQL INTO LV_GRID_SQL USING MODULEID;
         p_debug('a','5');
         LV_SQL := 'SELECT 0 SELECTED,CPARTY,DEAL_ID,SCHEME,TRAN_TYPE,ASSET_TYPE,ASSET_GROUP,VALUE_DATE FROM ( ';
         LV_SQL := LV_SQL || LV_GRID_SQL;
         LV_SQL := LV_SQL || ' ) WHERE DEAL_STATUS NOT IN (''DELETE'',''REJECT'') AND VALUE_DATE BETWEEN :1 AND :2 ORDER BY DEAL_ID';
    p_debug('a','6');
    OPEN REC_DEALDATA FOR LV_SQL USING FROM_DATE, TO_DATE;
    p_debug('a','7');
    RETURN;
    END;
    END IF;
    END Sp_Report_Manager;

  • How to execute a procedure with Object as OUT parameter

    Hi,
    I have a procedure and it consists 2 parameter, one is an input parameter and that is some ID (NUMBER datatype) and 2nd parameter is an out parameter and it an Object type. I want to execute that procedure but not able to do the same. Can anyone please suggest me how do I execute a procedure which has got Object as an out parameter.
    Thanks a lot in advance for your support.

    Example:
    SQL> create or replace type t_obj as object (ename varchar2(10), deptno number);
      2  /
    Type created.
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace procedure myproc (p_empno in number, obj out t_obj) is
      2  begin
      3    select t_obj(ename, deptno)
      4    into obj
      5    from emp
      6    where empno = p_empno;
      7* end;
    SQL> /
    Procedure created.
    SQL> set serverout on
    SQL> declare
      2    v_obj t_obj;
      3  begin
      4    myproc(7788, v_obj);
      5    dbms_output.put_line(v_obj.ename||','||v_obj.deptno);
      6  end;
      7  /
    SCOTT,20
    PL/SQL procedure successfully completed.

  • Registering the out parameter

    how to register an out parameter in java which is of %rowtype in pl/sql procedure

    Hi,
    Which version of Weblogic and JDBC driver do you use?
    Regards,
    Slava Imeshev
    "chaat" <[email protected]> wrote in message
    news:3c02da3a$[email protected]..
    >
    Hi,
    I'm using weblogic-jdriver driver, on Invoking a stored procedure(which
    returns a Record) by registering the OUT parameter as
    callableStatement.registerOutParameter(1, Types.ARRAY);
    the code compiles, @run time gives the following exception..
    java.sql.SQLException: Unknown type: 2003
    Exception Object info ==>[[The error code = 0 and  sql state = null ]].
    Any insights are greatly appreciated.

  • Performance issue with using out parameter sys_refcursor

    Hello,
    I'm using Oracle 10g, with ODP.Net in a C# application.
    I'm using about 10 stored procedures, each having one out parameter of sys_refcursor type. when I use one function in C# and call these 10 sp's, it takes about 78ms to excute the function.
    Now to improve the performance, I created one SP with 10 output parameters of sys_refcursor type. and i just call this one sp. the time taken has increased , not it takes abt 95ms.
    is this the right approach or how can we improve the performance by using sys_refcursor.
    please suggest, it is urgent, i'm stuck up with this issue.
    thanks
    shruti

    With 78ms and 95ms are you talking about milliseconds or minutes? If it's milliseconds then what's the problem and does it really matter if there is a difference of 17 milliseconds as that could just be caused by network traffic or something. If you're talking minutes, then we would need more information about what you are attempting to do, what tables and processing is going on, what indexes you have etc.
    Query optimisation tips can be found on this thread.. When your query takes too long ....
    Without more information we can't really tell what's happening.

  • Calling a stored procedure with a table of custom types as a out parameter

    Hi,
    I'm trying to use toplink 11.1.1.0.0 to call a stored procudure with 4 in paramrs and a single out parameter of type gsearch_type which is a userdefined type defined as below
    CREATE or replace TYPE search_object as object (mdlnumber varchar2(12), hit clob);
    create or replace type gsearch_type as table of search_object;
    Is it possible to get the return value from this stored procedure using toplink.
    Thanks in advance for any help.
    - Sunil

    Currently TopLink can't directly handle that kind of output parameter.
    As a workaround you would need a wrapper for the stored procedure - it could be either another stored procedure or an anonymous block which would return the components of the complex parameter as several simple parameters.

  • Procedure with table type out parameter

    Hi,
    I need to create a procedure which gives back a content of a table as an out parameter.
    i have tried something like below code
    it might not be correct since i am writing from home and cannot access any oracle db right now
    create or replace procedure test (
    table_out test_table%rowtype
    ) as
    type table_out test_table%rowtype
    begin
    select * into table_out
    from test_table
    where country = 'HUN';
    end;
    compile doesnt gives error, but when running it i get error
    declare
    table_out test_table%rowtype
    begin
    test( table_out );
    dbms_output.put_line( table_out );
    end;
    but it fails, could you help how to solve the above problem and call the proc correctly?
    thanks in advance

    Well you said you want the content of a table but your example says you just want a record. So for a record:
    CREATE OR REPLACE PROCEDURE sp_test (EMP_REC OUT EMP%ROWTYPE) IS
    BEGIN
        select * into emp_rec from emp where empno = 7369;
    END;The anonymous block to run it might be:
    declare
    tab_out emp%rowtype;
    begin
    sp_test(tab_out);
    dbms_output.put_line(tab_out.ename);
    end;As damorgan said the dbms_output can't be used with the record type. Notice I used it for the ENAME value of the record.
    If you really want the entire table then do it the way damorgan suggests. A pipeline function can give you the table but not as an OUT parameter.

  • Package with table data type as out parameter.

    Hi there, I managed to compile the package without error but when I am trying to test this package and
    I am keep facing this error message. 
    Am I using correctly for the table data type as out parameter.  I have no idea what is wrong with the package to fix. 
    Pls. help and advise me.  Thanks.
    Error starting at line 1 in command:
    DECLARE
    p_stmodel VARCHAR2(40):=null;
    p_item_number VARCHAR(40):='9BX158-300';
    p_item_id NUMBER:=0;
    l_attribute_out test_common_api.l_item_attr_tab:=test_common_api.l_item_attr_tab();
    BEGIN
    test_common_api.test_attribute(p_stmodel,p_item_number,p_item_id,l_attribute_out);
    END;
    Error report:
    ORA-06550: line 8, column 18:
    PLS-00302: component 'TEST_ATTRIBUTE' must be declared
    ORA-06550: line 8, column 2:
    PL/SQL: Statement ignored
    06550. 00000 -  "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    *Action:
    ---------Package.
    CREATE OR REPLACE PACKAGE test_common_api
    AS
    TYPE item_attr_rec IS RECORD (CONFIGURATION VARCHAR2(20),
                                   PRODUCTTYPE VARCHAR2(30),
                                   INTERNALPRODUCTNAME VARCHAR2(20),
                                   NUMBEROFHEADS VARCHAR2(2),
                                   NUMBEROFDISCS VARCHAR2(2),
                                   GENERATION  VARCHAR2(10),
                                   FACTORYAPPLICATION VARCHAR2(150),
                                   PRODUCTFAMILY  VARCHAR2(60),
                                   FORMFACTOR VARCHAR2(10),
                                   FORMATTEDCAPACITY NUMBER,
                                   FORMATTEDCAPACITY_UOM VARCHAR2(20),
                                   INTERFACE  VARCHAR2(30),
                                   SPINDLESPEEDRPM  NUMBER,
                                   PRODUCTCACHE VARCHAR2(10),
                                   WARRANTYMONTHS   VARCHAR2(2),
                                   PHYSICAL_SECTOR_SIZE  NUMBER,
                                   MODELHEIGHT  VARCHAR2(10),
                                   ENCRYPTION_TYPE VARCHAR2(40));
    TYPE l_item_attr_tab IS TABLE OF item_attr_rec;
    END test_common_api;
    show errors
    create or replace package body test_common_api
    AS
    PROCEDURE test_attribute (p_stmodel IN VARCHAR2,
                               p_item_number IN VARCHAR2,
                               p_item_id IN NUMBER,
                               l_item_attr_list OUT l_item_attr_tab)
    IS
    l_stmodel st.stmodelnumber%TYPE;
    l_market_segment VARCHAR2(10) ;
    l_sub_market_segment VARCHAR2(10) ;
    l_app_segment VARCHAR2(10);
    l_market_name VARCHAR2(40) ;
    l_ccitem seaeng_ccitemnumber.ccitemnumber%TYPE;
    l_query_item  VARCHAR2(1000);
    l_query_model VARCHAR2(1000);
    l_where VARCHAR2(1000);
    l_bind_var1      VARCHAR2(40);
    l_bind_var2      VARCHAR2(40);
    l_sql            NUMBER:=0;
    l_config VARCHAR2(40):=null;
    BEGIN
       IF p_stmodel is not null THEN
           l_where :='WHERE sc.ccmodel = sp.productmodelnumber AND sp.stmodelnumber = st.stmodelnumber
                      AND sc.pricingdescriptor=''MODEL''
                      AND sc.ccdashnumber =''000''
                      AND sp.detailedproductname=''GENERIC''
                      AND st.stmodelnumber= :1';
                  IF p_item_number is null AND p_item_id is null THEN
                      l_config :='null';
                  ELSE
                      l_config :='sc.configuration';
                  END IF;
            l_bind_var1 :=p_stmodel;
            l_sql :=1;
        ELSE
            IF p_item_id is null and p_item_number is not null THEN
                l_where := 'WHERE sc.ccmodel = sp.productmodelnumber AND sp.stmodelnumber = st.stmodelnumber and sc.ccitemnumber = :1';  
                l_bind_var1 :=p_item_number;
                l_sql:=2;
            ELSIF p_item_id is NOT null and p_item_number is null THEN
                l_where := 'WHERE sc.ccmodel= sp.productmodelnumber AND sp.stmodelnumber = st.stmodelnumber and sc.ccitemnumber in ( select msi.segment1
                            from mtl_system_items msi
                            where msi.inventory_item_id = :1)';
                l_bind_var1 := p_item_id;
                l_sql:=2;
            ELSIF p_item_id is not null and p_item_number is not null THEN
                l_where :='WHERE sc.ccmodel = sp.productmodelnumber AND sp.stmodelnumber = st.stmodelnumber and sc.ccitemnumber in (select msi.segment1
                           from mtl_system_items msi
                           where msi.inventory_item_id = :1
                           AND msi.segment1=:2)';
                l_sql:=3;
                l_bind_var1 := p_item_id ;
                l_bind_var2 :=p_item_number;
            END IF;
        END IF;
    l_query_item :='SELECT sc.configuration,st.producttype, sp.internalproductname, sp.numberofheads , sp.numberofdiscs,
      sp.generation,sp.factoryapplication, st.productfamily,st.formfactor , st.formattedcapacity , st.formattedcapacity_uom,
      st.interface,st.spindlespeedrpm,st.productcache,st.warrantymonths, st.physical_sector_size, st.modelheight, st.encryption_type
       FROM  pm sp , st st, seaeng_ccitemnumber sc ';
    l_query_model :='SELECT '|| l_config|| ' , st.producttype, null,null , null, null, sp.factoryapplication, null,st.formfactor, st.formattedcapacity,
      st.formattedcapacity_uom,st.interface , st.spindlespeedrpm, st.productcache, st.warrantymonths,st.physical_sector_size, st.modelheight,
      st.encryption_type
      FROM  pm sp , st st, seaeng_ccitemnumber sc ';
       IF l_sql = 1 THEN
          EXECUTE IMMEDIATE  l_query_model ||l_where
                             BULK COLLECT INTO l_item_attr_list
                             USING l_bind_var1 ;
                               dbms_output.put_line(l_query_model||l_where);
        ELSIF
             l_sql =2 THEN
               EXECUTE IMMEDIATE l_query_item || l_where
                                 BULK COLLECT INTO l_item_attr_list
                                 using l_bind_var1;
                                 dbms_output.put_line(l_query_item||l_where);
        ELSE
           EXECUTE IMMEDIATE  l_query_item ||l_where
                             BULK COLLECT INTO l_item_attr_list
                             USING l_bind_var1, l_bind_var2 ; 
                               dbms_output.put_line(l_query_item||l_where);
        END IF;
    END test_attribute;
    END test_common_api;
    show errors

    I think you forget to declare "PROCEDURE test_attribute" procedure in your package definition. like:
    CREATE OR REPLACE PACKAGE test_common_api
    AS
    TYPE item_attr_rec IS RECORD (CONFIGURATION VARCHAR2(20),
                                   PRODUCTTYPE VARCHAR2(30),
                                   INTERNALPRODUCTNAME VARCHAR2(20),
                                   NUMBEROFHEADS VARCHAR2(2),
                                   NUMBEROFDISCS VARCHAR2(2),
                                   GENERATION  VARCHAR2(10),
                                   FACTORYAPPLICATION VARCHAR2(150),
                                   PRODUCTFAMILY  VARCHAR2(60),
                                   FORMFACTOR VARCHAR2(10),
                                   FORMATTEDCAPACITY NUMBER,
                                   FORMATTEDCAPACITY_UOM VARCHAR2(20),
                                   INTERFACE  VARCHAR2(30),
                                   SPINDLESPEEDRPM  NUMBER,
                                   PRODUCTCACHE VARCHAR2(10),
                                   WARRANTYMONTHS   VARCHAR2(2),
                                   PHYSICAL_SECTOR_SIZE  NUMBER,
                                   MODELHEIGHT  VARCHAR2(10),
                                   ENCRYPTION_TYPE VARCHAR2(40));
    PROCEDURE test_attribute (p_stmodel IN VARCHAR2,
                               p_item_number IN VARCHAR2,
                               p_item_id IN NUMBER,
                               l_item_attr_list OUT l_item_attr_tab);
    TYPE l_item_attr_tab IS TABLE OF item_attr_rec;
    END test_common_api;
    show errors
    create or replace package body test_common_api
    AS
    PROCEDURE test_attribute (p_stmodel IN VARCHAR2,
                               p_item_number IN VARCHAR2,
                               p_item_id IN NUMBER,
                               l_item_attr_list OUT l_item_attr_tab)
    IS
    l_stmodel st.stmodelnumber%TYPE;
    l_market_segment VARCHAR2(10) ;
    l_sub_market_segment VARCHAR2(10) ;
    l_app_segment VARCHAR2(10);
    l_market_name VARCHAR2(40) ;
    l_ccitem seaeng_ccitemnumber.ccitemnumber%TYPE;
    l_query_item  VARCHAR2(1000);
    l_query_model VARCHAR2(1000);
    l_where VARCHAR2(1000);
    l_bind_var1      VARCHAR2(40);
    l_bind_var2      VARCHAR2(40);
    l_sql            NUMBER:=0;
    l_config VARCHAR2(40):=null;
    BEGIN
       IF p_stmodel is not null THEN
           l_where :='WHERE sc.ccmodel = sp.productmodelnumber AND sp.stmodelnumber = st.stmodelnumber
                      AND sc.pricingdescriptor=''MODEL''
                      AND sc.ccdashnumber =''000''
                      AND sp.detailedproductname=''GENERIC''
                      AND st.stmodelnumber= :1';
                  IF p_item_number is null AND p_item_id is null THEN
                      l_config :='null';
                  ELSE
                      l_config :='sc.configuration';
                  END IF;
            l_bind_var1 :=p_stmodel;
            l_sql :=1;
        ELSE
            IF p_item_id is null and p_item_number is not null THEN
                l_where := 'WHERE sc.ccmodel = sp.productmodelnumber AND sp.stmodelnumber = st.stmodelnumber and sc.ccitemnumber = :1';  
                l_bind_var1 :=p_item_number;
                l_sql:=2;
            ELSIF p_item_id is NOT null and p_item_number is null THEN
                l_where := 'WHERE sc.ccmodel= sp.productmodelnumber AND sp.stmodelnumber = st.stmodelnumber and sc.ccitemnumber in ( select msi.segment1
                            from mtl_system_items msi
                            where msi.inventory_item_id = :1)';
                l_bind_var1 := p_item_id;
                l_sql:=2;
            ELSIF p_item_id is not null and p_item_number is not null THEN
                l_where :='WHERE sc.ccmodel = sp.productmodelnumber AND sp.stmodelnumber = st.stmodelnumber and sc.ccitemnumber in (select msi.segment1
                           from mtl_system_items msi
                           where msi.inventory_item_id = :1
                           AND msi.segment1=:2)';
                l_sql:=3;
                l_bind_var1 := p_item_id ;
                l_bind_var2 :=p_item_number;
            END IF;
        END IF;
    l_query_item :='SELECT sc.configuration,st.producttype, sp.internalproductname, sp.numberofheads , sp.numberofdiscs,
      sp.generation,sp.factoryapplication, st.productfamily,st.formfactor , st.formattedcapacity , st.formattedcapacity_uom,
      st.interface,st.spindlespeedrpm,st.productcache,st.warrantymonths, st.physical_sector_size, st.modelheight, st.encryption_type
       FROM  pm sp , st st, seaeng_ccitemnumber sc ';
    l_query_model :='SELECT '|| l_config|| ' , st.producttype, null,null , null, null, sp.factoryapplication, null,st.formfactor, st.formattedcapacity,
      st.formattedcapacity_uom,st.interface , st.spindlespeedrpm, st.productcache, st.warrantymonths,st.physical_sector_size, st.modelheight,
      st.encryption_type
      FROM  pm sp , st st, seaeng_ccitemnumber sc ';
       IF l_sql = 1 THEN
          EXECUTE IMMEDIATE  l_query_model ||l_where
                             BULK COLLECT INTO l_item_attr_list
                             USING l_bind_var1 ;
                               dbms_output.put_line(l_query_model||l_where);
        ELSIF
             l_sql =2 THEN
               EXECUTE IMMEDIATE l_query_item || l_where
                                 BULK COLLECT INTO l_item_attr_list
                                 using l_bind_var1;
                                 dbms_output.put_line(l_query_item||l_where);
        ELSE
           EXECUTE IMMEDIATE  l_query_item ||l_where
                             BULK COLLECT INTO l_item_attr_list
                             USING l_bind_var1, l_bind_var2 ; 
                               dbms_output.put_line(l_query_item||l_where);
        END IF;
    END test_attribute;
    END test_common_api;
    show errors

  • Invoking Stored Procedure with OUT Parameter

    I am calling a stored procedure that has a "out" parameter of PL/SQL type (table of varchar2) through toplink API. My procedure executes, performs the updates successfully, but I can not obtain the value of the out parameter. Is the approach followed below incorrect? I could not figure out by looking into examples provided in the documentation:
    http://download.oracle.com/docs/cd/B25221_04/web.1013/b25386/building_and_using_application_services009.htm#BCFEFAHC
    Java function is given below:
    public List removeFromAutoupdSched( List srNumbers, String userName)
    if (srNumbers == null || srNumbers.size() == 0)
    return null;
    List result = null;
    try
    //Example Stored procedure call with an output parameter
    DatabaseLogin login = m_dbSess.getLogin();
    Connection conn = (Connection) (java.sql.Connection)login.connectToDatasource(null);
    oracle.sql.ArrayDescriptor arrDesc = new oracle.sql.ArrayDescriptor("AUTOUPD_SRLIST_T", conn);
    oracle.sql.ARRAY srARR = new oracle.sql.ARRAY(arrDesc, conn, srNumbers.toArray());
    StoredProcedureCall procCall = new StoredProcedureCall();
    procCall.setProcedureName("SEW_AUTOUPD.PURGE_AUTOUPD_SCHEDULE");
    procCall.addNamedArgumentValue("excludeSRlist", srARR);
    procCall.addNamedArgumentValue("exclude_by", userName);
    procCall.addNamedOutputArgument(
    "excludeSR_srlist_status",
    "excludeSR_srlist_status",
    OracleTypes.ARRAY,
    "AUTOUPD_SRLIST_ERRS_T"
    ValueReadQuery vq = new ValueReadQuery();
    vq.setCall(procCall);
    oracle.sql.ARRAY srResultARR = (oracle.sql.ARRAY)m_dbSess.executeQuery(vq);
    if (srResultARR != null)
    String[] msgs = (String[])srResultARR.getArray();
    if (msgs.length > 0)
    result = Arrays.asList(msgs);
    Iterator iter = result.iterator();
    while (iter.hasNext())
    System.out.println("msg = " + iter.next());
    return result;
    catch (Exception exc)
    throw new RuntimeException(exc);
    PL/SQL Type
    create or replace TYPE autoupd_srlist_errs_t IS TABLE OF VARCHAR2(150);
    Sample procedure called by toplink:
    PROCEDURE purge_autoupd_schedule(
    excludeSRlist autoupd_srlist_t,
    exclude_by VARCHAR2,
    excludeSR_srlist_status OUT NOCOPY autoupd_srlist_errs_t)
    IS
    pkg sew_log.pkg_name%TYPE default upper('sew_autoupd');
    prc sew_log.prc_name%TYPE default upper('purge_autoupd_schedule(excludeSRlist, exclude_by)');
    srno NUMBER;
    -- cnt NUMBER := 0;
    exclude_status VARCHAR2(150);
    err_prefix VARCHAR2(50) := 'Unable to exclude from autoupdate, ';
    BEGIN
    FOR i IN excludeSRlist.FIRST..excludeSRlist.LAST
    LOOP
    BEGIN
    srno := excludeSRlist(i);
    -- Update actn_taken column in autoupd_schedule before doing delete.
    UPDATE autoupd_schedule SET actn_taken='Removed by engineer', UPD_TIME=systimestamp
    WHERE sr_no = srno and engr_itsid = exclude_by;
    -- Add SR to exclusion list.
    INSERT INTO autoupd_exclude(sr_no, exclude_by, exclude_time) VALUES (srno, exclude_by, systimestamp);
    exclude_status := 'Item ' || i || ' - SR ' || srno || ' - ' || 'Excluded from autoupdate.';
    excludeSR_srlist_status(i) := exclude_status;
    EXCEPTION
    WHEN others THEN
    -- Add SR to excludeSR_fail if previous steps occurred okay.
    -- cnt := cnt +1;
    exclude_status := 'Item ' || i || ' - SR ' || srno || ' - ' || err_prefix || substr(sqlerrm,12);
    excludeSR_srlist_status(i) := exclude_status;
    END;
    END LOOP;
    EXCEPTION
    WHEN others THEN
    sew_logger.log(
    code => substr(sqlerrm,1,9),
    msg => substr(sqlerrm,12),
    pkg => pkg,
    prc => prc
    END;
    Any help is appreciated.

    What happens if you run the stored procedure through pure jdbc (without TopLink)?
    I tried a simple example that worked for me:
    //defined type in the db
    CREATE TYPE "TEST"."VAR_LIST" AS  TABLE OF VARCHAR2(150)
    //defined stored procedure in the db
    CREATE OR REPLACE  PROCEDURE "TEST"."VAR_LIST_IN_OUT"  (
    VARS_IN VAR_LIST,
    VARS_OUT OUT NOCOPY VAR_LIST
    as
    begin
      VARS_OUT := VAR_LIST();
      FOR i IN VARS_IN.FIRST..VARS_IN.LAST LOOP
        VARS_OUT.EXTEND;
        VARS_OUT(i) := CONCAT(VARS_IN(i), '_BLAH');
      END LOOP;
    end;
    // Java code
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("VAR_LIST_IN_OUT");
    Connection conn = (Connection) ((oracle.toplink.internal.sessions.AbstractSession)getSession()).getAccessor().getConnection();
    oracle.sql.ArrayDescriptor arrDesc = new oracle.sql.ArrayDescriptor("VAR_LIST", conn);
    oracle.sql.ARRAY srARR = new oracle.sql.ARRAY(arrDesc, conn, new String[]{"A1", "A2", "A3"});
    call.addNamedArgumentValue("VARS_IN", srARR);
    call.addNamedOutputArgument("VARS_OUT", "VARS_OUT", Types.ARRAY, "VAR_LIST");
    ValueReadQuery query = new ValueReadQuery();
    query.setCall(call);
    Object result = getSession().executeQuery(query);
    Object[] array = (Object[])((java.sql.Array)result).getArray();
    for(int i=0; i<array.length; i++) {
        System.out.println(array);
    // System.out:
    [TopLink Finest]: 2008.04.25 15:37:16.687--DatabaseSessionImpl(3491657)--Thread(Thread[main,5,main])--Execute query ValueReadQuery()
    [TopLink Fine]: 2008.04.25 15:37:16.703--DatabaseSessionImpl(3491657)--Connection(29118152)--Thread(Thread[main,5,main])--BEGIN VAR_LIST_IN_OUT(VARS_IN=>?, VARS_OUT=>?); END;
         bind => [oracle.sql.ARRAY@323274, => VARS_OUT] (There is no English translation for this message.)
    A1_BLAH
    A2_BLAH
    A3_BLAH
    My stored procedure didn't work (on Oracle 9 db) without output collection initialization: VARS_OUT := VAR_LIST(); and extending: VARS_OUT.EXTEND.

  • Oracle Instant Client and OUT Parameter of custom type in Stored Procedures

    Hi @ all!
    I try to set up a simple client application, that calls a stored procedure via Instant Client from C#.
    The stored procedure and assiciated types looks like this:
    TYPE MYVALUE AS OBJECT
          Id      INTEGER,
          value     FLOAT
    TYPE MYVALUELIST AS TABLE OF MYVALUE;
    PROCEDURE ReadValues( ID IN INTEGER,
                                        RESULTSET OUT MYVALUELIST)
                                           IS
    ...I created an Oracle Command executing this SP and added OracleParameters for ID and (where I got stuck) the RESULTSET.
    Is it possible to pass a parameter with a custom type from C# in some way?
    I already tried it as a function with SELECT * FROM TABLE(ReadValues(1));
    With my parameter RESULTSET as the RETURN type. But since I use DML within the procedure, this does not work inside of a query...
    Any suggestions?
    Thanks in advance!

    Hi Greg!
    Sorry, I misunderstood the forum topic then. =(
    Anyway, in the example you provided in the link, this is nearly exactly my situation. But there the Oracle.DataAccess.Client is used, where the OracleDBType can be called to initialize an object of type person. I use the instant client libraries called by using System.Data.OracleClient. There is only the OracleType enum, that does not contain an object or something similar.
    So I do it right now after trying a bit with a ref cursor parameter and an OracleDataAdapter - the ref cursor is passed back from Oracle as a DataReader, so die DataAdapter is able to use it for a .Fill():
    OracleCommand cmd = new OracleCommand();
    cmd.Parameters.Add("RESULTSET", OracleType.Cursor).Direction = ParameterDirection.Output;
    OracleDataAdapter odr = new OracleDataAdapter(cmd);
    DataTable result = new DataTable();
    odr.Fill(result);Within my stored procedure I just added the following OUT parameter:
    PROCEDURE ReadValues( ID IN INTEGER,
                                        RESULTSET OUT sys_refcursor)
                                           IS
    currentlist MYVALUELIST;
    ... [Adding elements to that list] ...
    OPEN resultset for select * from TABLE(currentlist);It works now, but I don't like that solution that much since I'm always afraid that there are lots of opened cursors idyling around. Do I have to close this one explicitly after filling my table by the DataAdapter?
    Regards

  • Pass a record type vaiable in out parameter of a function in a package

    Hi All,
    1.I have created a ecod inside a package.
    2.Then created a function which has a out parameter of the above record.
    3.Now package body i'm creating a dynamic cursor .
    4.My equirement is to fetch this dynamic cursor's value into the out parameter of the function.
    I have created the below code for 1,2 and 3 but not getting how to achive the point 4.
    create package pkg
    type t_rec is recod (id number,id_name varchar2(10));
    type t_data is table of t_rec index by binary_integer;
    act_data t_data;
    funcion return_data is (dept in number,region in number,o_rec out t_data) return boolean;
    end pkg;
    create package body pkg
    funcion return_data is (dept in number,region in number,o_rec out t_data) return boolean is
    p_cur sys_refcursor;
    l_text varchar2(100);
    begin
    -- As per my requirement i have built a dynamic l_text which contains where clause by taking dept and region values.In actual i have nearly 10 in paramaters with >which i'm building a dynamic where clause in l_text. So i'm using a ref cursor.
    open p_cur for 'select id,id_name from tab1'||l_text';
    fetch p_cur bulk collect into act_data;
    exception ....
    end pkg;Now as per the code snippet i could fetch all the rows returned by p_cur into act_data.
    But how i will pass it though out parameter in the function which i will use somewhere in front end to show data.
    Please help me in this.
    Thanks in advance.

    bp wrote:
    i need to create the where clause one the basis of the values of IN parameters.Sometimes i need to take count of the data on the basis of the IN parameters and if one of the conditions return value i will build where clause with those parameters.Please google and read up on the importance of creating shareable SQL - which needs to be done using bind variables.
    The ref cursor interface in PL/SQL only support a static/fixed number of bind variables. So if you want to create cursors with variable number of bind values, you need to use conditional processing. E.g.
    SQL> create or replace procedure EmpFilter( c OUT sys_refcursor, nameFilter varchar2, jobFilter varchar2 ) is
      2          sqlSelect       varchar2(32767);
      3  begin
      4          --// we pretend to built a dynamic SQL statement - so the table
      5          --// name and so on is "unknown"
      6          sqlSelect := 'select * from emp ';
      7          case
      8                  when nameFilter is null and jobFilter is null then
      9                          open c for sqlSelect;
    10
    11                  when nameFilter is null and jobFilter is not null then
    12                          sqlSelect := sqlSelect||'where job like :filter';
    13                          open c for sqlSelect  using jobFilter;
    14
    15                  when nameFilter is not null and jobFilter is null then
    16                          sqlSelect  := sqlSelect||'where ename like :filter';
    17                          open c for sqlSelect  using nameFilter;
    18
    19                  when  nameFilter is not null and jobFilter is not null then
    20                          sqlSelect  := sqlSelect||'where ename like :filter1 and job like :filter2';
    21                          open c for sqlSelect  using nameFilter, jobFilter;
    22
    23          end case;
    24
    25          DBMS_OUTPUT.put_line( 'Dynamic SQL: '||sqlSelect );
    26  end;
    27  /
    Procedure created.
    SQL>
    SQL>
    SQL> var c refcursor
    SQL> begin
      2          EmpFilter( :c, 'A%', null );
      3  end;
      4  /
    Dynamic SQL: select * from emp where ename like :filter
    PL/SQL procedure successfully completed.
    SQL> print c
         EMPNO ENAME      JOB              MGR HIREDATE                   SAL       COMM     DEPTNO
          7499 ALLEN      SALESMAN        7698 1981/02/20 00:00:00       1600        300         30
          7876 ADAMS      CLERK           7788 1987/05/23 00:00:00       1100                    20
    SQL>
    SQL> begin
      2          EmpFilter( :c, null, 'ANALYST' );
      3  end;
      4  /
    Dynamic SQL: select * from emp where job like :filter
    PL/SQL procedure successfully completed.
    SQL> print c
         EMPNO ENAME      JOB              MGR HIREDATE                   SAL       COMM     DEPTNO
          7788 SCOTT      ANALYST         7566 1987/04/19 00:00:00       3000                    20
          7902 FORD       ANALYST         7566 1981/12/03 00:00:00       3000                    20
    SQL>And this approach is for external clients - where a Visual Basic or Java client program calls the database, executes the stored procedure, and receives a cursor handle in turn. And the client then fetches the output of this cursor and process it.
    There is no need to return a record type of any sorts. The client wants the cursor handle as that is the optimal and best interface for the client to receive database data.
    If the caller is not an external client, but another PL/SQL procedure, then this approach does not make much sense.
    It is important that you understand basic Oracle concepts and fundamentals. What a cursor is. What the best way is to process Oracle data. How to best use the basic features of Oracle. Without that basic understanding, you as good as a low hour Cessna pilot getting into an Airbus A400M - where the Cessna pilot would not even be able to start a single engine, never mind get the plane in the air.
    Likewise, without a basic understanding of Oracle cursors and fundamentals, you will be unable to code even a single line of sensible code. Not because you are a bad programmer. Even the best programmer in the world will be unable to write decent code, if the programmer has no idea how the environment works, what the concepts and fundamentals are. But it is fair to expect that a good programmer will no write such code, understand that there is a lack of knowledge, and address that accordingly.

  • Error while calling a stored procedure with OUT parameter.

    Hi,
    I am trying to call a Stored Procedure(SP) with an OUT parameter(Ref Cursor) from a third party tool. It is called using OLE-DB Data provider. In one database the procedure works fine but when I change the database the procedure call is giving following error.
    Distribution Object:     COM Error. COM Source: OraOLEDB. COM Error message: IDispatch error #3092. COM Description: ORA-06550: line 1, column 7:
         PLS-00306: wrong number or types of arguments in call to 'TEST1'
         ORA-06550: line 1, column 7:
         PL/SQL: Statement ignored.
    I am not able to find as to why is this happening. Please let me know any clues /help to solve this problem.
    Thanks in advance.

    If you're using Oracle Provider for OLE DB (OraOLEDB) to execute this stored procedure, you need to set PLSQLRSet attribute. This attribute can be set in registry, connection string, or command object. Please refer to User Documentation for more information.

  • With JDBC, calling a stored procedure with ARRAY as out parameter

    Hi,
    I want to use the data type ARRAY as an out parameter in an Oracle stored procedure. I want to call the stored procedure from
    my java program using JDBC.
    The problem it's i use a 8.1.7 client to acces with oci to a 7.1.3 Database.
    With this configuration I can get back a Cursor but not an Array.
    Does it's possible ?
    Thanks for your help !
    Michakl

    Originally posted by JDBC Development Team:
    It's very similar to other datatype except that it uses OracleTypes.ARRAY typecode and the value is mapped to a oracle.sql.ARRAY instance. The code looks as follows --
    cstmt.registerOutParameter (idx, OracleTypes.ARRAY, "VARRAY_TYPE_NAME_HERE");
    cstmt.execute ();
    ARRAY array = (ARRAY) cstmt.getObject (idx);
    Thanks for your reply.
    I have to use:-
    OracleCallableStatement cs1 = (OracleCallableStatement )conn.prepareCall
    ( "{call proj_array(?)}" ) ;
    for retrieving a collection as an OUT parameter.
    This gives me the errors:-
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Blob getBlob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Array getArray(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Clob getClob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Ref getRef(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    How do I get rid of these errors?
    null

Maybe you are looking for

  • 2nd tier menus do not function

    Hi. I have a problem with menus on any application. If I click on Edit, and there is another menu off of that to the right, if I move my mouse to it, the menu disapears. However, if I hold the mouse button down, I can move to the option, and click th

  • IWeb update 1.1.1 will not install

    I'm trying to install the iWeb 1.1.1 update and always at the end it says there was an error and the installation stops. I have OSX 10.4.6 on an 800Mhz iMac, G4, with 512MB ram and I am updating from iWeb version 1.1 I have repaired prefs and re-star

  • Document not shown

    Dear SAP GURU, When My account officer have book the bill , at that time generate the Document Number 3100007116 Now the problem is that when we checked this document number 3100007116 The error massege are shown below Document 3100007116 does not ex

  • I want to display many records in the same jsp page

    Hi, i want to display many records with in the same jsp page providing the next,previous,first last . give me clear idea how to do that one note :only using servlets,jsp,jdbc and javascript

  • Sender FFC configuration

    Hi experts,      6.      Under Recordset Structure, enter the sequence and the number of substructures as follows: <NameA,nA,NameB,nB,...>, where nA=1,2,3,... or * (for a variable, unlimited number, including 0).        7.      You define the start a