Execute proc with out parameter

hi
I dont know whether this question fits this forum,eventhough i'm asking
how to execute a procedure in toad having out parameter
Edited by: user588120 on Sep 28, 2010 4:51 AM

declare
<variable> <variable type>;
begin
<your procedure>(<variable>);
end;
PL/SQL doc question.
Sybrand Bakker
Senior Oracle DBA

Similar Messages

  • Execute procedure with out parameter in sql*plus

    HI All,
    I am executing an stored proc with OUT parameter from sql*plus.
    Getting this error message:
    SQL> execute sp1_cr_ln_num('01',0,3);
    BEGIN sp1_cr_ln_num('01',0,3); END;
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to
    'sp1_cr_ln_num'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    Whereas it works fine using Toad. 4th parameter is for output.
    Thanks.

    then you can see the value either using print :var or execute dbms_output.put_line(:var)

  • Please help....execute procedure with out parameter -cursor

    HI all plese help me,
    i create a stored procedure like this.hw cani execute the IN out parameter which is a cursor ir..RCT1 is cursor..
    please help...
    CREATE OR REPLACE PROCEDURE ST_GetTravelTypeID
         TravelType IN      VARCHAR2 DEFAULT NULL,
         RCT1 IN OUT      GLOBALPKG.RCT1
    AS
    BEGIN
         OPEN RCT1 FOR
         SELECT
                   TravelTypeCode,
                   TravelTypeDesc
         FROM ST_MS_TravelTypes
         WHERE     TravelType = ST_GetTravelTypeID.TravelType;
    END;
    Message was edited by:
    neethu

    Your reference is invalid:
    WHERE TravelType = ST_GetTravelTypeID.TravelType;
    This should not (cannot) refer to the name of the procedure - but simply to the variable in it. I.e.
    WHERE TravelType = TravelType;
    However, as you can see, the variable name is now the same as the column name.
    One method around this is to use explicit scope reference. E.g.
    SELECT
      t.TravelTypeCode,
      t.TravelTypeDesc
    FROM  ST_MS_TravelTypes t
    WHERE t.TravelType = TravelType;I suggest that you consider this a standard for your PL/SQL programming. Always alias SQL tables in PL/SQL code and use explicit column references.
    Another standard we use is to use underscore characters for columns - camel case is fine for variables in a programming language. This is not really acceptable for column names, as by default Oracle uses uppercase. Thus "TravelType" is valid as variable name, but invalid as a column name - it should be defined/written as "travel_type" or "TRAVEL_TYPE" instead.

  • How to write a shell script to execute a procedure with out parameter

    Hi,
    How to write a shell script to execute a procedure with out parameter.
    here is my procedure
    PROCEDURE sample(invar1 VARCHAR2,
    invar2 VARCHAR2,
    invar3 VARCHAR2,
    invar4 VARCHAR2,
    ecode out number);
    Any example really helpfull
    Thanks in advance

    Or if we're passing values in, maybe something like:
    Test procedure:
    CREATE OR REPLACE PROCEDURE p (myin IN VARCHAR2, myout OUT VARCHAR2)
    AS
    BEGIN
        myout :=
            CASE myin
                WHEN 'A' THEN 'APPLE'
                WHEN 'B' THEN 'BANANA'
                ELSE 'STARFRUIT'
            END;
    END;Shell script:
    #!/bin/bash
    my_shell_variable=$1
    unset ORACLE_PATH
    sqlplus -s un/pw@db <<-EOF
    set feedback off pause off
    set pagesize 0
    set autoprint off
    VAR out varchar2(30)
    VAR myin varchar2(30)
    exec :myin := '${my_shell_variable}'
    BEGIN
      p(:myin, :out);
    END;
    print out
    exit
    EOFTest:
    /Users/williamr: xx A
    APPLE
    /Users/williamr: xx B
    BANANA
    /Users/williamr: xx
    STARFRUITObviously in a real script you would not hardcode the password or let it show in a "ps" listing.
    Message was edited by:
    William Robertson

  • Procedure with out parameter in if-then-else condition

    Hi,
    I want to fetch the out parameter of a procedure inside another procedure that has if-then-else condition.
    <<Proc1_start>>
    if ..
    then <<proc2_>> --- with out parameter
    end if;
    <<proc1_end>>
    How to do this...
    Thanks.

    Ummm, the same way you would do it anywhere else?
    Declare variable in proc1 to hold the output of proc2 and then call proc2.
    John

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

  • How to execute dynamically created procedure with out parameter

    hi guys ,
    friend i have to execute a procedure whose name is going to change dynamically and this procedure is have 2 out parameter . I need to capture value of these 2 output parameter, here i m giving my code also ..
    declare
    v_emp_id int :=100013 ;
    p_reg_off varchar(5) := 'R' ;
    p_user_id int := 6 ;
    v_status varchar(200);
    v_message varchar (200);
    v_Formula varchar(100);
    v_number int := 1 ;
    begin
    v_Formula := 'Call testsp_'||v_number||'('||v_emp_id||','''||p_reg_off||''','|| p_user_id || ',v_status,v_message)' ;
    DBMS_OUTPUT.PUT_LINE( v_Formula);
    execute immediate v_Formula;
    end ;
    and my procedure structure is like this
    CREATE OR REPLACE PROCEDURE testsp_1
    p_emp_id INT,
    p_reg_off CHAR,
    p_user_id INT,
    p_status OUT NOCOPY INT,
    p_message OUT NOCOPY VARCHAR2
    AS
    begin
    end ;
    please help me .....

    The Complete Syntax for Execute Immediate is ::
    EXECUTE IMMEDIATE dynamic_sql_string
    [INTO {define_variable,... | INTO record_name}]
    [USING
    IN bind_argument,...]
    [RETURN[ING] INTO
    bind_argument,...];
    i think now it won't be a problem! ;)

  • Executing procedures with OUT parameters using Named notation

    I have a procedure with two out parameters (p_errortext and p_returncode) and i want to execute this proc in SQL*plus using named notation(using association operator ' => '). For position based execution i usually declare variables to hold the OUT parameter's value. But how can i do this while executing using named notation (using => )
    begin
         packagename.generate_ref_record(p_userid  => 'THELMA',
                                      p_ref_code       => '9A',
                                      p_item_id    => '9990000011163',
                                      p_shipno     => '0PH',
                                      p_errortext  =>  ??
                                      p_returncode =>  ??);
    end;

    SQL>variable x varchar2(30);
    SQL>variable y varchar2(30);
    SQL>exec packagename.generate_ref_record(p_userid  => 'THELMA',     
                                          p_ref_code       => '9A',       
                                          p_item_id    => '9990000011163',     
                                          p_shipno     => '0PH',     
                                          p_errortext  =>  :x        
                                          p_returncode =>  :y);

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

  • 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) {}

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

  • About JDBC CALL STORE PROCEDURE with out parameter is greater than 4000

    Hi Guys,
    I have a problem call store procedure with a large string.
    as i know varchar2 can contain 32767 characters in pl/sql .
    But when i used varchar2 as a out parameter in a store procedure, if the out parameter is greater than 4000 characters , it always give me error message as 'the buffer is too small'.
    why it happened?
    I read some article that says i need configure a property in data-source.xml , and jdbc 10g driver already solved this problem, but i used jdev 10.1.3.2 ,the driver should be fine.
    How can i solve this problem?
    Thanks in advance,
    AppCat

    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) {}

  • Trouble with OUT parameter when creating a PL/SQL process on a HTML page

    I would like to call a stored procedure when creating process on a HTML page.
    I do know how to call the proc with the IN parameters,
    its the OUT parameter that I am having a problem with.
    ..basically getting "wrong number of arguments"
    ..the procedure parameters
    DELETECONFIG(p_configname IN,
    p_configtype IN,
    p_successmsg OUT)
    I have two items on the page for the
    configtype and configname..so my call when creating the process looks like this
    DELETECONFIG(P_CONFIGNAME => :CONFIGNAME_LIST,
    P_CONFIGTYPE => :CONFIGTYPE_LIST,
    not sure how to handle p_successmsg..
    thank you.

    thank you.
    This worked for me, where :P122_XDISPLAY is a display only text area withou a label.
    BEGIN
    DELETECONFIG(:P122_XCONFIGUSERID,
    :P122_XCONFIG_TYPE,
    :P122_XCONFIG_NAME,
    :P122_XDISPLAY);
    END;

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

  • Calling a procedure from Oracle Forms with OUT parameter

    HI,
    Can anyone tell me in detail how to call a procedure with OUT parameters from Oracle Forms 6i ?
    Thanks in advance.

    Hello,
    Just provide the out parameter in the call:
    Declare
      amount   number; -- OUT number argument populated by the procedure
    Begin
      -- call the X procedure --
      x( amount ) ;
    End;Francois

Maybe you are looking for

  • How to insert a PDF document into a Word file?

    I'm using Acrobat Standard 9 and Microsoft Word 2010 and I'm unable to insert a PDF document into a Word file. Operating system is Windows 7 Enterprize. Can someone help?

  • flexunit 4.1 B3 Ant task fails to run Air-based tests

    Folks, I am using FlexUnit4.1 Beta 3 and am seeing the <flexunit> Ant task fail when running tests that use the Air libraries. The project in question used to test just fine with version 4.0 earlier this year, but I just dusted it off after a branch

  • Artists not appearing

    I downloaded 6 songs from a CD. When I go under artists, the name of the song appears, not the band. The name of the song appears in the Album category as well. How do I change this so I can scroll by artist??

  • Changing the System in the desktoplaunch/InfoView Log in

    We are on BO XI SP3 (Windows) and recently installed the BO application on a new server.  We did copied our old respository over.   So the "System" on the login screen shows our old server information and I would like to update this.   Can you tell m

  • Iam trying to create FI-CA contracts...

    Hi FI-CA experts, I am trying to create a contract using FM: BAPI_CTRACCONTRACTACCOUNT_CR1  and i am passing all the relevant BP data to it. But iam getting this 1 error: Message class: >3 061                 You cannot maintain category &1 contract