Executing a Stored Procedure with OUT Variables

When you execute a stored proc withi OUT variables, do you have to add in the "Declare" section and "Begin/End" sections? Or can you just use "EXECUTE <stored proc>"??

When you execute a stored proc withi OUT variables, do you have to add in the "Declare" section and "Begin/End" sections?
Or can you just use "EXECUTE <stored proc>"?? You mean this?:
michaels>  create or replace procedure p (o out varchar2)
as
begin
   o := 'Some out variable';
end p;
Procedure created.
michaels>  var o varchar2(50)
michaels>  exec p(:o)
PL/SQL procedure successfully completed.
michaels>  print o
o                                                
Some out variable                                

Similar Messages

  • How can I execute a Procedure with OUT variable is %ROWTYPE on SQL Prompt

    Hi,
    I have a procedure with OUT variable is %ROWTYPE
    How can I execute the following procedure on SQL prompt.
    (without creating anonymous block)
    CREATE OR REPLACE PROCEDURE zz_sp_EMP(VEMPNO IN EMP.EMPNO%TYPE,
    V_REC IN OUT EMP%ROWTYPE)
    AS
    BEGIN
    SELECT * INTO V_REC FROM EMP WHERE EMPNO = VEMPNO;
    END;
    Thanks & Regards,
    Naresh

    as previous posters said: it's not possible to do this without declaring a variable in the anonymous block.
    With anonymous block it would look like this (had to change it a bit, since i'm using hr-schema on oracle XE):
    declare
    l_rec EMPLOYEES%ROWTYPE;
    begin
    zz_sp_EMP(VEMPNO => 100, V_REC => l_rec);
    DBMS_OUTPUT.PUT_LINE ( 'first_name = ' || l_rec.first_name );
    DBMS_OUTPUT.PUT_LINE ( 'last_name = ' || l_rec.last_name );
    end;
    first_name = Steven
    last_name = King

  • Oracle Stored Procedure with out parameter

    Good morning,
    Is it possible to use an Oracle stored procedure with out parameters in MII ?
    If yes, what is the manipulation to see the values of parameters Out?
    Thank you

    Michael,
    This is the  MII query template  :
    DECLARE
    STRCOMPTERENDU NVARCHAR2(200);
    BEGIN
    STRCOMPTERENDU := NULL;
    XMII.SP_VALIDATEPROCESSORDERSLIST2 ( STRCOMPTERENDU => [Param.1]  );
    COMMIT;
    END;
    and the stocked procedure code
    CREATE OR REPLACE PROCEDURE XMII.SP_ValidateProcessOrdersList2(strCompteRendu OUT nVarchar2) IS
    tmpVar NUMBER;
    debugmode INT;
    strClauseSql varchar(2048);
    strListPOactif varchar(1024);
    dtmTimeStamp DATE;
       NAME:       SP_ValidateProcessOrdersList
       PURPOSE:   
       REVISIONS:
       Ver        Date        Author           Description
       1.0        18/06/2008          1. Created this procedure.
       NOTES:
       Automatically available Auto Replace Keywords:
          Object Name:     SP_ValidateProcessOrdersList
          Sysdate:         18/06/2008
          Date and Time:   18/06/2008, 18:45:32, and 18/06/2008 18:45:32
          Username:         (set in TOAD Options, Procedure Editor)
          Table Name:       (set in the "New PL/SQL Object" dialog)
    BEGIN
       tmpVar := 0;
       debugmode := 0;
       -- lecture date systeme pour time stamp
       select sysdate  into dtmTimeStamp from dual;
       if debugmode = 1 then
        DBMS_OUTPUT.put_line('SP_ValidateProcessOrdersList');
       end if;
       -- insertion du bloc dans le log
       insert into LOG_ORDER
        (DATE_ORDER,BLOCK_ORDER,ID_LOG_ORDER)
       values
       (dtmTimeStamp,'SP_ValidateProcessOrdersList',ID_LOG_ORDER.nextval);
       Commit;
        if debugmode = 1 then
        DBMS_OUTPUT.put_line('insertion LOG OK');
       end if;
    strCompteRendu := '0123456-896;0123456-897';
    commit; 
       EXCEPTION
         WHEN NO_DATA_FOUND THEN
           NULL;
         WHEN OTHERS THEN
         ROLLBACK;
         -- insertion du bloc dans le log
       insert into LOG_ORDER
        (DATE_ORDER,BLOCK_ORDER,ID_LOG_ORDER)
       values
       (dtmTimeStamp,' ',ID_LOG_ORDER.nextval);
       COMMIT;
           -- Consider logging the error and then re-raise
           RAISE;
    END SP_ValidateProcessOrdersList2;
    Thanks for your help
    Alexandre

  • How to execute a stored procedure with an out parameter ?

    Guys I am struggling with executing a stored procedure from sql plus.I mean my stored procedure has 2 input parameter and 1 out put parameter (status of the execution).
    MY_PROCEDURE(p_name in varchar2,p_age in number,p_status out varchar2)
    end my_procedure;
    When I say
    EXECUTE MY_PROCEDURE('manohar','Shetty');
    i get insufficient parameters errors.
    please help.

    EXECUTE isn't a valid PL/SQL construct. It's a SQL*Plus command. You don't want to put any SQL*Plus commands in a PL/SQL block.
    You can always execute a stored procedure purely through PL/SQL
    begin
      my_stored_procedure( x, y, z );
    end;SQL*Plus happens to give you the execute command so you can avoid the begin and end statements.
    Justin

  • Call stored procedure with OUT parameter

    Hello,
    I have created a short-lived process. Within this process I am using the "FOUNDATION > JDBC > Call Stored Procedure" operation to call an Oracle procedure. This procedure has 3 parameters, 2 IN and 1 OUT parameter.
    The procedure is being executed correctly. Both IN parameters receive the correct values but I am unable to get the OUT parameter's value in my process.
    Rewriting the procedure as a function gives me an ORA-01460 since one of the parameters contains XML (>32K) so this is not option...
    Has someone been able to call a stored procedure with an OUT parameter?
    Regards,
    Nico

    Object is Foundation, Execute Script
    This is for a query, you can change to a stored procedure call. Pull the value back in the Java code then put into the process variable.
    import javax.naming.InitialContext;
    import javax.sql.DataSource;
    import java.sql.*;
    PreparedStatement stmt = null;
    Connection conn = null;
    ResultSet rs = null;
    try {
    InitialContext ctx = new InitialContext();
    DataSource ds = (DataSource) ctx.lookup("java:IDP_DS");
    conn = ds.getConnection();
    stmt = conn.prepareStatement("select FUBAR from TB_PT_FUBAR where PROCESS_INSTANCE_ID=?");
    stmt.setLong(1, patExecContext.getProcessDataLongValue("/process_data/@inputID"));
    rs = stmt.executeQuery();
    rs.next();
    patExecContext.setProcessDataStringValue("/process_data/outData", rs.getString(1));
    } finally {
    try {
    rs.close();
    } catch (Exception rse) {}
    try {
    stmt.close();
    } catch (Exception sse) {}
    try {
    conn.close();
    } catch (Exception cse) {}

  • 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.

  • Calling Oracle stored procedure with out param of user define type from Entity Framework 5 with code first

    Guys i am using Entity Framework 5 code first (I am not using edmx) with Oracle and all works good, Now i am trying to get data from stored procedure which is under package but stored procedure have out param which is user define type, Now my question is
    how i will call stored procedure from entity framework
    Thanks in advance.

    I agree with you, but issue is we have lots of existing store procedure, which we need to call where damn required. I am sure those will be few but still i need to find out.
    If you think you are going to get existing MS Stored Procedures  or Oracle Packages that had nothing to do with the ORM previously to work that are not geared to do simple CRUD operations with the ORM and the database tables, you have a rude awakening
    coming that's for sure. You had better look into using ADO.NET and Oracle Command objects and call those Oracle Packages by those means and use a datareader.
    You could use the EF backdoor, call Oracle Command object and use the Packages,  if that's even possible, just like you can use MS SQL Server Stored Procedures or in-line T-SQL via the EF backdoor.
    That's about your best shot.
    http://blogs.msdn.com/b/alexj/archive/2009/11/07/tip-41-how-to-execute-t-sql-directly-against-the-database.aspx

  • Calling Oracle Stored procedure with OUT parameter from ODI

    Hi,
    I called an oracle stored procedure with following anonymous block in the ODI procedure.
    Declare
    Status varchar2(10);
    Begin
    OTM.DeleteTarget('E_KPI_TARGET_VALUE', Status);
    End;
    I want to capture the OUT parameter STATUS value in a project level variable.
    And based on its va;lue I would like to choose between 2 interfaces in my package.
    Please help me in doing this.

    Hi,
    For that kind of situation I commoly use:
    1) one step with:
    create or replace package <%=odiRef.getSchemaName("W")%>.pck_var
    Status varchar2(10);
    end;
    * transaction 9, for instance
    2) step
    Begin
    OTM.DeleteTarget('E_KPI_TARGET_VALUE', <%=odiRef.getSchemaName("W")%>.pck_var.Status);
    End;
    * transaction 9
    3) then, at an ODI variable, use a refresh like:
    select <%=odiRef.getSchemaName("W")%>.pck_var.Status from dual
    at same logical shema where the package was created.
    Does it make sense to you?

  • How to execute plsql stored procedure with DbAccess

    sessionInfo object can give DbAccess .through
    which u can use javax.infobus.DbAccess API to
    execute sql satement and stored procedures according to infobus API .iam able to
    execute simple query by using executeCommand() ,executeRetrival() ?. how to execute stored procedures with executeRetrieval() .
    how to take in and out parameters
    suggestions are welcome
    waiting for your suggestions

    I am also looking for the same.
    Did you get any info on this
    Thanks,
    jagan
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by chandra sekhar ([email protected]):
    sessionInfo object can give DbAccess .through
    which u can use javax.infobus.DbAccess API to
    execute sql satement and stored procedures according to infobus API .iam able to
    execute simple query by using executeCommand() ,executeRetrival() ?. how to execute stored procedures with executeRetrieval() .
    how to take in and out parameters
    suggestions are welcome
    waiting for your suggestions<HR></BLOCKQUOTE>
    null

  • Executing the stored procedure with output which is a collection of objects

    Hello,
    I have the objects and collection of objects within an objects as below:
    CREATE OR REPLACE TYPE SHARE_OUTST_T
    AS OBJECT
    SHR_OUTST_AMT     number
    CREATE OR REPLACE TYPE SECURITY_T
    AS OBJECT
         VOTE_PER_SHR     number
    , CUSIP     varchar2(12)
    , EXCHANGE     varchar2(10)
    , IV_TYPE_CD     varchar2(10)
    , SEC_TICKER_SYMB     varchar2(20)
    CREATE OR REPLACE TYPE ALTERNATE_ID_T
    AS OBJECT
    ( ALT_ID_TYPE     varchar2(20)
    CREATE OR REPLACE TYPE ISSUE_MAINT_VERSION_T
    AS OBJECT
         IM_KEY_ID number     
    ,     IM_VER_NUM number
    ,     EFF_TMSTMP timestamp
    , EXP_TMSTMP timestamp
    ,     NEXT_REVIEW_TMSTMP timestamp
    ,     APPR_STATUS_REF_ID number
    , VOTE number
    , ADD_USR_ID varchar2(20)
    , ADD_TMSTMP timestamp
    , UPD_USR_ID varchar2(20)
    , UPD_TMSTMP timestamp
    , LOCK_LEVEL_NUM number
    , ACTION VARCHAR2(1)
    CREATE OR REPLACE TYPE ISSUE_SHARE_MAINT_T
    AS OBJECT
         IM_KEY_ID      number     
    ,     IM_VER_NUM      number
    ,     SHR_OUTST_AMT      number
    ,     CURR_OUTST_AMT     number
    ,      ADD_USR_ID      varchar2(20)
    ,      ADD_TMSTMP      timestamp
    ,      UPD_USR_ID      varchar2(20)
    ,      UPD_TMSTMP      timestamp
    ,      LOCK_LEVEL_NUM      number
    ,     ACTION     VARCHAR2(1)
    CREATE OR REPLACE TYPE ISSUE_MAINT_COMMENT_T
    AS OBJECT
         IM_KEY_ID      number     
    ,     IM_VER_NUM      number
    ,     COMMENT_TXT     varchar2(400)
    ,      ADD_USR_ID      varchar2(20)
    ,      ADD_TMSTMP      timestamp
    ,      UPD_USR_ID      varchar2(20)
    ,      UPD_TMSTMP      timestamp
    ,      LOCK_LEVEL_NUM      number
    ,     ACTION     VARCHAR2(1)
    CREATE OR REPLACE TYPE ISSUE_MAINT_COMMENT_COL_T AS TABLE OF ISSUE_MAINT_COMMENT_T;
    CREATE OR REPLACE TYPE ISSUE_VERSION_T
    AS OBJECT
         SHARE_OUTST     SHARE_OUTST_T
    ,     SECURITY     SECURITY_T
    ,     ALTERNATE_ID     ALTERNATE_ID_T
    ,     ISSUER     ISSUER_T
    ,     ISSUE_MAINT_VERSION     ISSUE_MAINT_VERSION_T
    ,     ISSUE_SHARE_MAINT     ISSUE_SHARE_MAINT_T
    , ISSUE_MAINT_COMMENT_COL ISSUE_MAINT_COMMENT_T
    CREATE OR REPLACE TYPE ISSUE_VERSION_COL_T AS TABLE OF ISSUE_VERSION_T;
    And the stored procedure as :
    =======================================
    PROCEDURE get_all_issue_version_col
    ( pv_issue_version_col OUT issue_version_col_t
    AS
    CURSOR cur_issue_version
    IS
    SELECT
    issue_version_t (
    SHARE_OUTST_T (so.shr_outst_amt )
    , SECURITY_T ( s.vote_per_shr
    , s.sec_cusip
    , s.PRI_MKT_EXCH_CD
    , s.IV_TYPE_CD
    , s.SEC_TICKER_SYMB )
    , ALTERNATE_ID_T (a.ALT_ID_TYPE)
    , ISSUER_T (i.ISSR_ID )
    , ISSUE_MAINT_VERSION_T (imv.im_key_id
    , imv.im_ver_num
    , imv.eff_tmstmp
    , imv.exp_tmstmp
    , imv.next_review_tmstmp
    , imv.appr_status_ref_id
    , imv.vote
    , imv.add_usr_id
    , imv.add_tmstmp
    , imv.upd_usr_id
    , imv.upd_tmstmp
    , imv.lock_level_num
    , NULL )
    , ISSUE_SHARE_MAINT_T (ism.im_key_id
    , ism.im_ver_num
    , ism.shr_outst_amt
    , ism.curr_outst_amt
    , ism.add_usr_id
    , ism.add_tmstmp
    , ism.upd_usr_id
    , ism.upd_tmstmp
    , ism.lock_level_num
    , NULL)
    , ISSUE_MAINT_COMMENT_T(imc.im_key_id
    , imc.im_ver_num
    , imc.comment_txt
    , imc.add_usr_id
    , imc.add_tmstmp
    , imc.upd_usr_id
    , imc.upd_tmstmp
    , imc.lock_level_num
    , NULL )
    FROM
    share_outst so
    , security s
    , alternate_id a
    , issuer i
    , issue_maintenance_version imv
    , issue_share_maintenance ism
    , issue_maintenance_comment imc
    WHERE
    s.sec_key_id = so.SEC_KEY_ID
    and s.SEC_KEY_ID = a.SEC_KEY_ID
    and s.MSTR_ISSR_KEY_ID = i.ISSR_KEY_ID
    and s.SEC_CUSIP = imv.SEC_CUSIP (+)
    and s.SEC_CUSIP = ism.SEC_CUSIP (+)
    and imv.IM_KEY_ID = imc.IM_KEY_ID (+);
    BEGIN
    OPEN cur_issue_version ;
    FETCH cur_issue_version BULK COLLECT INTO pv_issue_version_col ;
    CLOSE cur_issue_version ;
    END ;
    PROCEDURE get_all_issue_col_v1
    ( pv_issue_version_col OUT NOCOPY issue_version_col_t
    , pv_row_count IN number
    , pv_issuer_id IN VARCHAR2
    AS
    CURSOR cur_issue_version
    IS
    SELECT
    issue_version_t (
    SHARE_OUTST_T (so.shr_outst_amt )
    , SECURITY_T ( s.vote_per_shr
    , s.sec_cusip
    , s.PRI_MKT_EXCH_CD
    , s.IV_TYPE_CD
    , s.SEC_TICKER_SYMB )
    , ALTERNATE_ID_T (a.ALT_ID_TYPE)
    , ISSUER_T (i.ISSR_ID )
    , ISSUE_MAINT_VERSION_T (imv.im_key_id
    , imv.im_ver_num
    , imv.eff_tmstmp
    , imv.exp_tmstmp
    , imv.next_review_tmstmp
    , imv.appr_status_ref_id
    , imv.vote
    , imv.add_usr_id
    , imv.add_tmstmp
    , imv.upd_usr_id
    , imv.upd_tmstmp
    , imv.lock_level_num
    , NULL )
    , ISSUE_SHARE_MAINT_T (ism.im_key_id
    , ism.im_ver_num
    , ism.shr_outst_amt
    , ism.curr_outst_amt
    , ism.add_usr_id
    , ism.add_tmstmp
    , ism.upd_usr_id
    , ism.upd_tmstmp
    , ism.lock_level_num
    , NULL)
    , ISSUE_MAINT_COMMENT_T(imc.im_key_id
    , imc.im_ver_num
    , imc.comment_txt
    , imc.add_usr_id
    , imc.add_tmstmp
    , imc.upd_usr_id
    , imc.upd_tmstmp
    , imc.lock_level_num
    , NULL )
    FROM
    share_outst so
    , security s
    , alternate_id a
    , issuer i
    , issue_maintenance_version imv
    , issue_share_maintenance ism
    , issue_maintenance_comment imc
    WHERE
    s.sec_key_id = so.SEC_KEY_ID
    and s.SEC_KEY_ID = a.SEC_KEY_ID
    and s.MSTR_ISSR_KEY_ID = i.ISSR_KEY_ID
    and s.SEC_CUSIP = imv.SEC_CUSIP (+)
    and s.SEC_CUSIP = ism.SEC_CUSIP (+)
    and imv.IM_KEY_ID = imc.IM_KEY_ID (+);
    BEGIN
    OPEN cur_issue_version ;
    FETCH cur_issue_version BULK COLLECT INTO pv_issue_version_col ;
    CLOSE cur_issue_version ;
    END ;
    ====================
    When I execute this stored procedure thru rapid sql, I get error
    Error: ORA-06550: line 1, column 21:
    PLS-00306: wrong number or types of arguments in call to 'GET_ALL_ISSUE_VERSION_COL'
    ORA-06550: line 1, column 21:
    PL/SQL: Statement ignored, Batch 1 Line 1 Col 21
    What is that I am missing?
    Any help would be greatly appreciated.

    I've never tried Rapid SQL, but my guess is that you can't pass objects through it. I'd write a test case on the server and try it there. It looks like it should work but I didn't build a test case. If it works on the server but not in the tool, it's like the tool. OCI8 doesn't support passing instantiated objects.

  • Execute immediate for stored procedure with out parameter

    Hi,
    I have problem with dynamically executing the statement hope anyone can help me.
    I have a table which stores the procedure names. and procedure parameter values are stored on another column with parameter values coming from java side.
    I have to create a procedure that dynamically executes the procedure on table1 with the values from table 2.
    Now I'm getting real trouble to execute immediate this proc with parameters. I tried the DBMS_SQL package as well.
    Problem is you need to mention the OUT mode specifically for the out parameter. Can anybody plz help me with this issue??
    TABLE1_
    PROCESS_ID     PROC_NAME
    1      proc1(p1 IN number, p2 IN varchar2, p3 OUT varchar2)
    2     proc2(p1 IN number, p2 out varchar2, p3 OUT varchar2)
    TABLE2_
    PROCESS_ID     PROC_PARMS
    1     100, 'test', :return
    2     200, :return1, :return2
    Thank You

    826957 wrote:
    Hi,
    I have problem with dynamically executing the statement hope anyone can help me.
    I have a table which stores the procedure names. and procedure parameter values are stored on another column with parameter values coming from java side.
    I have to create a procedure that dynamically executes the procedure on table1 with the values from table 2.
    Now I'm getting real trouble to execute immediate this proc with parameters. I tried the DBMS_SQL package as well.
    Problem is you need to mention the OUT mode specifically for the out parameter. Can anybody plz help me with this issue??
    TABLE1_
    PROCESS_ID     PROC_NAME
    1      proc1(p1 IN number, p2 IN varchar2, p3 OUT varchar2)
    2     proc2(p1 IN number, p2 out varchar2, p3 OUT varchar2)
    TABLE2_
    PROCESS_ID     PROC_PARMS
    1     100, 'test', :return
    2     200, :return1, :return2
    Thank YouSounds like an appalling design and a nightmare waiting to happen.
    Why not have your Java just call the correct procedures directly?
    Such design smells badly of an entity attribute value modelling style of coding. Notoriously slow, notoriously buggy, notoriously hard to maintain, notoriously hard to read. It really shouldn't be done like that.

  • 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.

  • How to call oracle stored procedure with OUT parameter?

    I create oracle stored procedure in eclipse oepe
    PROCEDURE SP_SELECT_ORA (
    ID_INPUT IN VARCHAR2,
    ID_OUTPUT OUT VARCHAR2,
    PASSWD_OUTPUT OUT VARCHAR2,
    NAME_OUTPUT OUT VARCHAR2) IS
    BEGIN
    SELECT EMP_ID, EMP_Passwd, EMP_Name
    INTO ID_OUTPUT, PASSWD_OUTPUT, NAME_OUTPUT
    FROM family
    WHERE EMP_ID = ID_INPUT;
    END;
    and I try to call the sp in jpa like below,
    @NamedNativeQueries({
         @NamedNativeQuery(name = "callSelectSP", query = "call SP_SELECT_ORA(?,?,?,?)", resultClass = Members.class)
    @Entity
    @Table(name="family")
    public class Members implements Serializable {
         @Id
         @Column(name = "EMP_ID")
         private String ID;
         @Column(name = "EMP_Passwd")
         private String Passwd;
         @Column(name = "EMP_Name")
         private String Name;
    ==============
    @PersistenceContext(unitName="MyFamily")
         EntityManager em;
    query = em.createNamedQuery("callSelectSP");
         query.setParameter(1, ID);
         String id_output = null;
         String passwd_output = null;
         String name_output = null;
         query.setParameter(2,id_output);
         query.setParameter(3,passwd_output);
         query.setParameter(4,name_output);
         query.executeUpdate();
         member = (Members)query.getSingleResult();
    But this query throws exception,
    19:55:35,500 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http--127.0.0.1-8080-1) SQL Error: 1465, SQLState: 72000
    19:55:35,500 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http--127.0.0.1-8080-1) ORA-01465: invalid hex number
    I don't know how. Pls, give me your advice. Thanks in advnace.
    Best regards

    Thank you for your reply, Chris!
    I tried this one.
    @NamedNativeQueries({
    @NamedNativeQuery(name = "callSelectSP", query = "exec SP_SELECT_ORA( ?, :id_output, :passwd_output, :name_output) " , resultClass = Members.class)
    @Entity
    @Table(name="family")
    public class Members implements Serializable
    ===================
    query = em.createNamedQuery("callSelectSP");
    query.setParameter(1, ID);
    String id_output = null;
    String passwd_output = null;
    String name_output = null;
    query.setParameter("id_output", id_output);
    query.setParameter("passwd_output", passwd_output);
    query.setParameter("name_output",name_output);
    query.executeUpdate();
    On Console hibernate shew the sql and ora # like below,
    19:59:25,160 INFO [stdout] (http--127.0.0.1-8080-1) Hibernate: exec SP_SELECT_ORA( ?, ?, ?, ?)
    19:59:25,192 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http--127.0.0.1-8080-1) SQL Error: 900, SQLState: 42000
    19:59:25,192 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http--127.0.0.1-8080-1) ORA-00900: Invalid SQL statement
    Pls, inform me your advice. Thanks in advance.
    Best regards.

  • Problems calling stored procedure with out ref cursors

    Hi,
    I am calling an oracle stored procedure and having problems. This is the code:
    ResultSet cursor1, cursor2, cursor3, cursor4,cursor5,cursor6;
    String sql = "BEGIN SYSADM.PKG_SERVICE.SERV_MAIN(:1,:2,:3,:4,:5,:6,:7,:8,:9) \n; END;";
    CallableStatement call = null;
    try
    call = conn.prepareCall(sql);
    call.setString(1,blah1);
    call.setString(2,blah2);
    call.setString(3,blah3);
    call.registerOutParameter(4,OracleTypes.CURSOR);
    call.registerOutParameter(5,OracleTypes.CURSOR);
    call.registerOutParameter(6,OracleTypes.CURSOR);
    call.registerOutParameter(7,OracleTypes.CURSOR);
    call.registerOutParameter(8,OracleTypes.CURSOR);
    call.registerOutParameter(9,OracleTypes.CURSOR);
    call.execute();
    cursor1 = ((OracleCallableStatement) call).getCursor(4);
    cursor2 = ((OracleCallableStatement) call).getCursor(5);
    cursor3 = ((OracleCallableStatement) call).getCursor(6);
    cursor4 = ((OracleCallableStatement) call).getCursor(7);
    cursor5 = ((OracleCallableStatement) call).getCursor(8);
    cursor6 = ((OracleCallableStatement) call).getCursor(9);
    on the cursor1 = line I get this exception:
    06/08/08 15:07:01 java.lang.ClassCastException: com.evermind.sql.FilterCallableStatement
    this is a web service running in JDeveloper 10.1.2
    Dennis

    Dennis,
    There is only one "data-sources.xml" file in my JDeveloper 10.1.3. It is in the "\j2ee\home\config" subdirectory.
    But the again, I have not used my JDeveloper to create any Web services.
    I really think you should try the JDeveloper and ADF forum.
    Also, there are several debug properties you can set for OC4J.
    Since you say you are using 10.1.2, the following Web page may be helpful:
    http://www.oracle.com/technology/tech/java/oc4j/htdocs/oc4j-logging-debugging-technote.html
    Good Luck,
    Avi.

  • Stored Procedure with bind variables

    Hello,
    I have problems when executing this sample code:
    Procedure Test (..., in_Param IN CHAR, ...)
    Query_Str := 'Select * from Table1 where column1 IN :in_Param';
    Open Cursor1 For Query_Str Using in_Param;
    This Cursor retuns rows when in_Param is 'A'
    This Cursor does not return any row if in_Param is ('A', 'B')
    Can you please help to track the error in this Query?
    Many thanks

    It seems to be that the bind variable is treated as a single discrete object. Hence
    'Select * from Table1 where column1 IN :in_Param';
    is functionally the same as
    'Select * from Table1 where column1 = :in_Param';
    so when in_Param is ('A', 'B'), what actually gets executed is
    Select * from Table1 where column1 = 'A, B';
    Not surprisingly this returns no rows.
    You can of course do this:
    'Select * from Table1 where column1 in( :x, :y, :z)';
    Open Cursor1 For Query_Str Using :i, :j, :k;
    So you could parse in_param yourself, populating the unused variables with nulls, so that if in_param = ('A, B') then i=A, j=B and k=null. Given that in 8i an IN string can have 1000 variables this could be a right mare if you don't put a cap on in_param.
    Your alternative is not to use a bind variable for this statement.
    rgds, APC

Maybe you are looking for