Execute stored procedure from DOS or Unix Shell

Hi, need ur help again,
How to execute the stored procedure from DOS or Unix Shell?
Thanks!

sqlplus -s /NOLOG @your_sql_script.sql
-- your_sql_script.sql :
connect user/password@connect_string
execute package.procedure (param1, param2, ...) -- for packages
execute procedure (param1,...) -- for procedures
exit ;this way you won't advertise your user/password on unix systems

Similar Messages

  • Execute Stored Procedures from Stellent

    Can we execute stored procedures from stellent 7.5.2 ?
    By using java, I dont find any method to execute stored procedure from WorkSpace interface.
    Please guide me to solve this..
    Appreciate your help and efforts.

    May not be exactly what you're looking for, but I hope this helps:
    http://www.corecontentonly.com/Blog/Calling-A-Stored-Procedure-From-Oracle-Fusion-ECM-Stellent
    For java based execution basically:
    1. Create your stored proc in the db
    2. Create a component
    3. Create a query resource
    4. In your java code use the createResultSet method of the Workspace object and pass in the name of your query resource and then the current databinder object

  • Execute stored procedure from Unix shell script

    My current method of executing stored procedures (wpl_1 and wpl_2) from a unix shell script is as follows:
    <<wpl.sh>>
    sqlplus user/password @/home/oracle/scripts/wpl.sql
    <<wpl.sql>>
    set serveroutput on size 1000000
    set timing on
    execute wpl_1('0000010676','~')
    execute wpl_2('0000010676','~')
    execute wpl_1('0000010236','FIX')
    execute wpl_2('0000010236','FIX')
    exit
    Question: Is it possible to combine the two scripts (unix and oracle) together?

    A little rusty on this, but this may work:
    My current method of executing stored procedures
    (wpl_1 and wpl_2) from a unix shell script is as
    follows:
    <<wpl.sh>>sqlplus user/password @/home/oracle/scripts/wpl.sql << EOF
    set serveroutput on size 1000000
    set timing on
    execute wpl_1('0000010676','~')
    execute wpl_2('0000010676','~')
    execute wpl_1('0000010236','FIX')
    execute wpl_2('0000010236','FIX')
    exit
    EOF
    >
    Question: Is it possible to combine the two scripts
    (unix and oracle) together?

  • Executing Stored procedure from host file

    Hi all,
    I am trying to execute a procedure from a host file.I don't know where I am doing wrong but the procedure is not executing.
    #!/bin/bash
    echo "*********************** Initializing Global Variables ***********************"
    export CONNECT_STRING=$1
    export START_TIME=`date +%m/%d/%Y:%H%M`
    #export DATE_FROM=`date +%m/%d/%Y:%H%M`
    #export DATE_TO=`date +%m/%d/%Y:%H%M`
    DATE_FROM=$5
    DATE_TO=$6
    sqlplus -S -S -S -S -S -S -S -S -S -S -S -S -S -S -S -S -S -S -S -S -S -S -S -S -S -S -S -S -S -S ${CONNECT_STRING} <<EOF
        WHENEVER SQLERROR EXIT FAILURE
        set echo off
        execute xxjy_extract_ar_transactions.main_preinterface('$DATE_FROM','$DATE_TO');
    EOF
    echo "From Date is $DATE_FROM"
    echo "To Date is $DATE_TO" In my log i can see the From Date is 1-Jan-2013 and To date is 28-Feb-2013 which are my input parameters to concurrent program.But I don't understand why my procedure is not getting called.
    Please advice.
    Thanks,
    Sandeep

    Please post the details of the application release, database version and OS.
    Is the issue with this specific host concurrent program?
    Did you follow the steps in these docs?
    How to Register a Host Concurrent Program in Applications [ID 156636.1]
    How To Create A Custom Concurrent Program With Host Method and Pass Parameters To The Shell Script [ID 266268.1]
    How Do You Run A Unix Host Script From Concurrent Managers On MS Windows Platform? [ID 412392.1]
    How To Setup A Custom Concurrent Host Program [ID 147455.1]What is the reason of using more than one "-S" in the sqlplus command?
    Please enable trace and generate the TKPROF file to find out what is happening when you kick off this concurrent program?
    FAQ: Common Tracing Techniques within the Oracle Applications 11i/R12 [ID 296559.1]
    How To Trace a Concurrent Request And Generate TKPROF File [ID 453527.1]
    Thanks,
    Hussein

  • Facing error while trying to execute stored procedure from JSF Application

    Hi, I am facing the below error when I try to execute a stored Procedure from JSF application which is deployed on WAS 7.0
    =2013-03-04 19:06:58,550 INFO [com.lloydstsb.iw.util.DBUtils] - DBUtils : executeFileNetStoredProc method started..
    =2013-03-04 19:11:58,271 ERROR [com.lloydstsb.iw.dao.FileNetCustomDBSynchDAOImpl] - Data Access Exception
    com.lloydstsb.iw.common.exceptions.DataAccessException: Data Access Exception Occured : Integration Stored Proc- java.sql.SQLException: java.lang.ClassCastException: oracle.jdbc.driver.LogicalConnection incompatible with oracle.jdbc.OracleConnection
         at com.lloydstsb.iw.util.DBUtils.executeFileNetStoredProc(DBUtils.java:959)
         at com.lloydstsb.iw.util.DAOUtil.executeFileNetStoredProc(DAOUtil.java:117)
         at com.lloydstsb.iw.dao.FileNetCustomDBSynchDAOImpl.updateFileNetDetailsCustomDB(FileNetCustomDBSynchDAOImpl.java:36)
         at com.lloydstsb.iw.servlet.IndexServlet.service(IndexServlet.java:127)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
         at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1443)
         at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:790)
         at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:443)
         at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:175)
         at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:91)
         at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:859)
         at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1557)
         at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:173)
         at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
         at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
         at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
         at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
         at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
         at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
         at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
         at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:202)
         at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:766)
         at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:896)
         at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1527)
    The oracle version we are using is 11g.
    Previously it worked fine when the application was used in 10g.
    Can someone please help me in resolving this issue?
    Kiran
    Edited by: 991640 on Mar 4, 2013 8:25 PM

    java.lang.ClassCastException: oracle.jdbc.driver.LogicalConnection incompatible with oracle.jdbc.OracleConnection
    Are the the JDBC JARs packaged with the application? If so, remove the applicaiton packaged JDBC JARs as the JARs are also in WebSphere application server.

  • Problem in executing Stored Procedure from Trigger

    Hi,
    Case1.
    I am executing a stored procedure form a trigger. The stored procedure is not executing fully.
    Case 2.
    But when when I execute Stored Procedure alone it is executing.
    CREATE OR REPLACE TRIGGER mhubadmin.call_proc_ratesheet_new
    after INSERT OR delete ON mhubadmin.pvt_br_ratesheet
    FOR EACH ROW
    declare
    var_orgid number;
    begin
    if inserting then
    select org_child_id into var_orgid from business_relationship where br_id=:new.br_id;
    mhubadmin.proc_ratesheet_new(var_orgid);
    else
    select org_child_id into var_orgid from business_relationship where br_id=:old.br_id;
    mhubadmin.proc_ratesheet_new(var_orgid);
    end if;
    end;
    CREATE OR REPLACE PROCEDURE proc_ratesheet_new(var_orgid in number)
    IS
    cursor c3 is select distinct(purs.user_id) from hubuser hu
    inner join PVT_USER_RATESHEET purs on hu.USER_ID=purs.USER_ID
                   where hu.ORG_ID=var_orgid;
    cursor c1(varUser_id number) is select purs.user_id,purs.ratesheet_id from hubuser hu
    inner join PVT_USER_RATESHEET purs on hu.USER_ID=purs.USER_ID
                   where hu.ORG_ID=var_orgid and purs.USER_ID=varUser_id;
    cursor c2(varUser_id number) is select hu.user_id,pbr.ratesheet_id from HUBUSER hu
                             inner join BUSINESS_RELATIONSHIP br on hu.ORG_ID=br.ORG_CHILD_ID
                             inner join PVT_BR_RATESHEET pbr on br.BR_ID=pbr.BR_ID
                                  where hu.user_id in(select distinct(purs.USER_ID) from hubuser hu
                                       inner join PVT_USER_RATESHEET purs
                                                                     on hu.USER_ID=purs.USER_ID
                                                 where hu.ORG_ID=var_orgid) and hu.user_id=varUser_id;
    foundFlag boolean;
    incrFound integer;
    insertFound integer;
    deleteFound integer;
    str varchar2(4000);
    BEGIN
         incrFound:=0;
         insertFound:=0;
         for c3var in c3 loop
    for c2var in c2(c3var.user_id) loop
              insert into test values ('Step3:'||c2var.user_id);
              foundFlag:=false;
              for c1var in c1(c3var.user_id) loop
                   if c2var.ratesheet_id=c1var.ratesheet_id then
                        foundFlag:=true;
                             incrFound:=incrFound+1;
                             exit;
                        end if;
                   end loop;
                   if foundFlag=False then
                   --insert into pvt_user_ratesheet (username_ratesheet_id,user_id,ratesheet_id) values (SEQ_USER_RATESHEET.nextval,c3var.user_id,c2var.ratesheet_id);
                   dbms_output.put_line('Inserted for user :'||c3var.user_id||' is - ratesheet :'||c2var.ratesheet_id);
                   insertFound:=insertFound+1;
                   end if;
              end loop;
    end loop;
         commit;
         incrFound:=0;
         deleteFound:=0;
         for c3var in c3 loop
              for c1var in c1(c3var.user_id) loop
              foundFlag:=false;
              for c2var in c2(c3var.user_id) loop
                        if c1var.ratesheet_id=c2var.ratesheet_id then
                        foundFlag:=true;
                        incrFound:=incrFound+1;
                        exit;
                        end if;
                   end loop;
                   if foundFlag=False then
                   --delete from pvt_user_ratesheet where user_id=c3var.user_id and ratesheet_id=c1var.ratesheet_id;
                        --dbms_output.put_line('Deleted for userid:'||c3var.user_id||' for ratesheet :'||c1var.ratesheet_id);
                        deleteFound:=deleteFound+1;
                   end if;
              end loop;
    end loop;
         commit;
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.put_line (SQLCODE||' '|| SQLERRM);
    END;
    Regards,
    Mathew

    In general, I would suggest that you only catch errors that you can handle reasonably. If you know that a SELECT INTO might return 0 rows for example, handle the NO_DATA_FOUND exception. Having a WHEN OTHERS, particularly without re-raising the exception, only serves to hide the source of the problem. I would much rather that my code fail quickly and explicitly than hope that I see an error message in the output and that other code doesn't start failing because the system wasn't left in an appropriate state.
    As Mark suggests, you may choose to implement a comprehensive logging framework using autonomous transactions, in which case a WHEN OTHERS would be reasonable, but you would still want to propagate exceptions you cannot handle.
    If you see a WHEN OTHERS clause and there is no RAISE, you probably have an error waiting to happen.
    Justin

  • Execute stored procedure from TestStand

    I am having difficulty executing a stored procedure from the TestStand Database step types.  I am using the "Data Operation" step type to set the input parameter, but I still get the following error;
    Procedure or function 'sproc_prior step' expects parameter '@serial_number', which was not supplied.
    I've attached the sequence file for review.
    Any help would be appreciated.
    Attachments:
    db Stored Procedure1.seq ‏9 KB

    We were able to fix this sequence by making the following changes:
    1.) In the Open SQL Statement change the Command Type to Stored Procedure instead of Default.
    2.) On the Get Results step change the Operation to Get - Retrieve Values from Record instead of Close since the Close SQL Statement takes care of that for you.
    3.) Also change the Record To Operate On to Current - Use Current Record.
    After making these changes the sequence should work.  Also note, that it would be preferable to change the stored procedure name to us all underscores and not spaces since this is more standard for use with databases.
    John B.
    Applications Engineer
    National Instruments

  • Execute stored procedure from batch file

    Hi,
    can someone helpme hoe to run my stored procedure from a bacth file. I need it urgently. Can some one help
    Thanks,
    Sri

    Hi,
    You can perform the below step..
    1) Create .sql file and write the line as shown below there....
    exec your_procedure_name
    2) create .bat file containing authentication
    sqlplus username/password@databasename @.sqlfilename
    suppose i have a procedure called test then and my database name is oracle and user name is scott then i will create a file like
    .sql file.. and sql file name is proc.sql
    exec test {(parameter if any)};
    .bat file
    sqlplus scott/tiger@oracle @procIf you have any issue past here..

  • Executing Stored Procedure from TOAD: ORA-00900: invalid SQL statement

    Ok…I have ALL the stored procedures converted into Oracle…now, when I go to test them I am getting the vague error of:
    ORA-00900: invalid SQL statement
    I am attempting to execute:
    --EXEC IEXGetAgentSysPerf(to_date('2008/09/01', 'yyyy/mm/dd/'), to_date('2008/09/11', 'yyyy/mm/dd'), 'US HelpDesk');
    EXEC IEXGetAgentSysPerf('9/1/2008', '9/11/2008', 'US HelpDesk');
    (Neither work). These are calling a Stored Procedure with the following header:
         PROCEDURE IEXGetAgentSysPerf (
              v_curparm_IEXGetAgentSysPerf     IN OUT      pkg_IEX.cur_IEXGetAgentSysPerf
              ,v_BDateTime     DATE
              ,v_EDateTime     DATE
              ,v_WorkGroup     VARCHAR2
    The IDE is “TOAD” for Oracle. Thanks in advance.

    Hi,
    This is your procedure
    PROCEDURE IEXGetAgentSysPerf (
    v_curparm_IEXGetAgentSysPerf IN OUT pkg_IEX.cur_IEXGetAgentSysPerf
    ,v_BDateTime DATE
    ,v_EDateTime DATE
    ,v_WorkGroup VARCHAR2
    you are providing the ,v_BDateTime DATE,v_EDateTime DATE and v_WorkGroup
    and how about "v_curparm_IEXGetAgentSysPerf ". So that procedures is returning the error.
    Adding the the earlier post, If you want to test the Stored Procedures... then I say you work on the PL/SQL
    Developer which good for debugging (easy to use...) When compare to TOAD.. :-)
    Test ..it there...
    - Pavan Kumar N

  • Execute Stored Procedure from C#

    Hi, im new to using stored procedures and i have the following stored procedure...
    CREATE OR REPLACE PROCEDURE DRL_PROCEDURE2(var_SOURCE_OBJECTID IN varchar2, var_NEW_OBJECTID OUT varchar2)
    AS
    BEGIN
    SELECT MAX(NEW_OBJECTID)
    INTO var_NEW_OBJECTID
    FROM DRL_CONVERSION
    WHERE SOURCE_OBJECTID = var_SOURCE_OBJECTID;
    END;
    I want to be able to call this procedure from my windows form application and display the result of the stored procedure into a label...could someone please help me! Thanks in advance!

    http://www.csharpfriends.com/articles/getarticle.aspx?articleid=78
    You can find how to call stored procedure (in the above link you will find an example of SQL Server 2005 which also work for you as of your oracle stored procedure) in C#.
    HTH
    Girish Sharma

  • In JDBC Sender Adapter , the server is Microsoft SQL .I need to pass current date as the input column while Executing stored procedure, which will get me 10 Output Columns. Kindly suggest me the SQL Query String

    In JDBC Sender Adapter , the server is Microsoft SQL .I need to pass current date as the input column while Executing stored procedure, which will get me 10 Output Columns. Kindly suggest me the SQL Query String , for executing the Stored Procedure with Current date as the input .

    Hi Srinath,
    The below blog might be useful
    http://scn.sap.com/community/pi-and-soa-middleware/blog/2013/03/06/executing-stored-procedure-from-sender-adapter-in-sap-pi-71
    PI/XI: Sender JDBC adapter for Oracle stored procedures in 5 days
    regards,
    Harish

  • Calling stored procedure from unix shell script

    Hello,
    I am facing a problem while calling a stored procedure from UNIX shell script. I want to return a output variable from the stored procedure to the UNIX environment.
    Here is the code-
    #!/bin/sh
    OUTPUT=`sqlplus cmag/magnum@dw <<ENDOFSQL
    set serveroutput on;
    var prd_out varchar2(100);
    exec create_pm_window(:prd_out);
    exit;
    ENDOFSQL`
    echo " output is - $OUTPUT"
    The problem is :prd_out is not getting copied to shell variable OUTPUT.
    I have a dbms_output.put_line in the stored proc create_pm_window and I can see that prd_out is getting populated.
    Any help is really appreciated.
    Thanks'
    Rakhee

    First step :
    make sure the PL/SQL works as expected.
    Does the following display the expected output executed from SQL*Plus ?
    set serverout on
    declare
    prd_out varchar2(100);
    begin
    create_pm_window(prd_out);
    dbms_output.put_line('output is '||prd_out);
    end;
    I don't have your procedure, but using a dummy procedure like :
    Scott@my10g SQL>create procedure foo(p_out in out varchar2)   
      2  is
      3  begin
      4  select 'Hello '||instance_name into p_out from v$instance;
      5  end;
      6  /
    Procedure created. and a toto.sh script as :OUTPUT=`sqlplus -s scott/tiger <<EOF
    set pages 0 lines 120 trimout on trimspool on tab off echo off verify off feed off serverout on
    var mavar varchar2(100);
    exec foo(:mavar);
    print mavar;
    exit;
    EOF`
    echo "OUT = ${OUTPUT}"
    exitIt works fine :[oracle@Nicosa-oel ~]$ ./toto.sh
    OUT = Hello my10g

  • Running stored procedure from unix shell

    Hi
    I have a stored procedure proc1 stored in a file, code1.txt in my home directory /home/user. How do i execute this file which contains the stored procedure from unix shell? I would really appreciate it if somebody gives me the complete shell script to accomplish the above task.
    Thanks.

    To put everything together into a single posting:
    The EXEC command is a SQL*Plus macro command. It is not a SQL or PL/SQL command.
    The only way to execute a stored proc from a client, is to wrap the call in an anonymous PL/SQL block. I.e you need a BEGIN and END PL/SQL wrapper around the call.
    E.g.BEGIN
      -- calling a stored proc to start leave processing
      scott.StartLeaveProcessing;
    END;The EXEC macro in SQL*Plus does this automatically for you. Thus less typing. But do not confuse this command with the PL/SQL language.
    Second issue. Use bind variables when making calls from clients. And not just for SQL statements, but also for PL/SQL. Unfortuantely this tends to be a hack in SQL*Plus due to the way SQL*Plus itself treats its bind variable assignments. But in principle, this is what you should do when calling an Oracle stored proc from a client:
    SQL> -- define a host variable
    SQL> var EMPID varchar2(100)
    SQL> var FROM_DEPT number
    SQL> var TO_DEDPT number;
    SQL>
    SQL> -- assign values to these (this is where SQL*Plus hacks it)
    SQL> exec :EMPID := 100;
    SQL> exec :FROM_DEPT := 1;
    SQL> exec :TO_DEPT := 2;
    SQL>
    SQL> -- now make the stored proc call for moving employee 100 from
    SQL> -- department 1 to department 2
    SQL> EXEC scott.EmployeeTransfer( :EMPID, :FROM_DEPT, :TO_DEPT );
    SQL>To do this from a Unix shell script:
    #!/bin/bash
    # environment variables
    # --> put environment such as ORACLE_HOME, ORACLE_SID, TWO_TASK
    # etc. here <--
    # redirect STDIN from TTY (keyboard typewriter device) to the input from
    # this file - which means SQL*Plus will not read from the keyboard but read
    # from this file its input until the EOF marker/text is encountered
    sqlplus -s /nolog << EOF
    connect scott/tiger
    var EMPID varchar2(100)
    var FROM_DEPT number
    var TO_DEDPT number;
    exec :EMPID := 100;
    exec :FROM_DEPT := 1;
    exec :TO_DEPT := 2;
    exec scott.EmployeeTransfer( :EMPID, :FROM_DEPT, :TO_DEPT );
    exit;
    EOF
    #eof

  • Calling pl/sql stored procedure from shell script ( kshell)

    hello.,
    i have written a stored procedure. i need to call this stored procedure from a unix shell script ( korn shell).
    can anyone please help me how can i do it.actually there are 3 stored procedures. so my shell script has to call each stored procedure, execute it then go to next stored procedure execute it.
    if by chance inbetween any stored procedure do not execute then the shell script has to tell me that this stored procedure failed to execute.
    please help me in this.
    thanks
    madan

    Sorry Madan,
    Following is the complete solutiion:
    !# /usr/bin/ksh
    sqlplus -s user/pass@server << EOF > a.log
    exec proc1;
    exec proc2;
    exec proc3;EOF
    if [ $? -eq 0 ]
    then
            echo "\n Procedures completed successfully at `date`"
    else
            echo "!!! FAILED!!!"
            echo "Details can be found in a.log File"
    fi

  • Executin oracle stored procedure from shell script

    Hi everyone,
    I want to know how to execute a orace stored procedure from a shell script not a sql file.
    Its a oracle stored procedure with in parameters.
    Can anyone send immediate reply its very urgent.
    Thanks in Advance
    with regards
    Thazul

    Hello everyone,
    Whenever i am using the previous script
    because of <<! and !>> in the beginging and the end of oracle scrip. Shell is displaying the error 'newline or ;' unxexpeted and the error no is 48.
    After that i used a different script like
    DIRRUNNER=/oracle/tvg
    count=0
    while [ 1 -eq 1 ]
    do
    for x in `ls $DIRRUNNER/RUNNER_*.TXT`
    do
    count=`grep -c $x $DIRRUNNER/runner.log`
    if [ $count -lt 1 ]
    then
    chstr=`echo $x|awk -F/ '{printf $NF }'`
    dir=$DIRRUNNER
    file=$chstr
    PATH=$PATH:/usr/local/bin:.
    export PATH
    ORACLE_SID=BBPROD
    ORAENV_ASK=NO
    . oraenv
    ORAENV_ASK=YES
    echo "exec runrace('$dir', '$file')" > runner.sql
    sqlplus -s tvgus/tvgus@bbprod @runner.sql
    echo $x >>$DIRRUNNER/runner.log
    fi
    done
    count=0
    sleep 2
    done
    The above one is working fine but after executing the procedure control is still remaing in the sqlplus environment, but i want the control back to my shell
    Can anyone help to resolve this, its pretty urgent.
    Thanks in Advance
    Thazul.
    null

Maybe you are looking for