Executing a stored proc from inside a stored proc

Hi,
I'm trying to execute a stored procedure from inside another stored procedure, and I can't seem to work out the correct syntax to use, could someone please give me a pointer, it's starting to drive me insane :]
CREATE OR REPLACE PROCEDURE foo (blah in type) AS
BEGIN
EXEC OTHER_STORED_PROC();
END;
Thank you kindly,
Anthony...

EXEC is a SQL*Plus command, not PL/SQL syntax. In SQL*Plus, EXEC <<procedure name>> is just shorthand for
BEGIN
  <<procedure name>>
END;Calling a stored procedure from another stored procedure (or any PL/SQL block), can bypass the extra begin/end pair because it's already inside a PL/SQL block. Thus, the syntax you need is just
CREATE OR REPLACE PROCEDURE foo (bar IN type)
AS
BEGIN
  other_stored_procedure();
END;Justin
Distributed Database Consulting, Inc.
www.ddbcinc.com/askDDBC

Similar Messages

  • Call stored proc from inside sp

    I am trying to call a stored proc from inside a stored proc and the stored proc needs to return a ref_cursor. I am trying to loop over the returned ref_cursor, but my problem is that when I compile the sp it says the ref_cursor is not a procedure or is undefined. Can anyone please tell me why I am getting this error? Refer to the code below!
    create or replace
    PROCEDURE TCS_GetPartReferenceData
    contracts IN VARCHAR2
    , showInWork IN INTEGER
    , userClock IN VARCHAR2
    , intMaxResults IN INTEGER
    , ret_cursor OUT SYS_REFCURSOR
    ) AS
    p_cursor SYS_REFCURSOR;
    BEGIN
    TCS_GETDRNSFORCONTRACTS(contracts
    , showinwork
    , userClock
    , intmaxresults
    , p_cursor);
    for r in p_cursor loop
    dbms_output.put_line(r.puid);
    end loop;
    END TCS_GetPartReferenceData;

    Probably you want sth. like
    CREATE OR REPLACE PROCEDURE tcs_getpartreferencedata (contracts       IN     VARCHAR2,
                                        showinwork      IN     INTEGER,
                                        userclock       IN     VARCHAR2,
                                        intmaxresults   IN     INTEGER,
                                        ret_cursor         OUT sys_refcursor)
    AS
    BEGIN
       tcs_getdrnsforcontracts (contracts,
                                showinwork,
                                userclock,
                                intmaxresults,
                                ret_cursor);
    END tcs_getpartreferencedata;
    var cur refcursor
    exec tcs_getpartreferencedata(contracts_value,showinwork_value,userclock_value,intmaxresults_value, :cur)
    print curfill in appropriate values for the parameters _value ....                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to execute linux sh command from inside CF

    I am using CFMX 7,0,0,91690 Enterprise on Redhat Enterprise Linux 4.9 with Apache webserver 2.0.52.  I have a coldfusion template that queries from a Postgresql 8.0 database, copies the data from the queries into a set of files in one folder on the linux server, and then has a CFEXECUTE tag at the very end that calls a bash shell script on the same server. The shell script takes the files from the one folder, merges some of their content together, moves them to another folder, adds header and footer, and sets ownership and permissions.  These 2 scripts have been in place and working perfectly for several years now. No changes were made to content, permissions, or ownershop of scripts.  Suddenly last Friday the coldfusion script seems to have lost its ability to execute the shell script properly.  It does execute it and the shell script attempts to do some of the steps, but the resulting files are missing the content and have the linux environmental variables and their values displayed instead.  Clearly its getting an error but that is not being reported back to me. After the CF script ends, if I manually execute the shell script from the linux command line, it works perfectly. I tried giving it more permissions but that did not help.  Redhat support suggests I run the script with "sh -x" to get more detailed output for debugging, but I would need to do that from inside the CF script since that is where the problem is.  Is it possible to execute a shell script from inside a CF script using a linux "sh" command in some way (instead of the cfexecute, just so I can see debugging info)? Thanks in advance for any suggestions. Julie

    Thanks for the suggestion, tried that too:
    <cfexecute name="/bin/sh" arguments="-x /bin/siscopy" outputfile="/home/coldfusion/sh_output.txt" timeout="600" />
    still didn't work.  Script ends with this coldfusion error:  Timeout period expired without completion of /bin/sh
    It does not complete the task of making the files, and the sh_output.txt file which is supposed to capture the -x output, is empty.
    Thanks,
    Julie

  • Execute a shell script from inside PL procedure

    Oracle 9205 on Red Hat Enterprise Linux 3.
    Is there any way to execute an O.S. shell script from inside a PL/SQL procedure?
    This is, that PL_SQL procedure evaluate a situation and if the condition is true, it calls and execute an O.S. shell script.

    PL/SQL procedures do not support any native calls to the OS; however, you can code calls to external procedures or JAVA procedures to perform tasks on the OS.
    Prior to these two methods any of the following packages dbms_alert, dbms_pipe, or utl_file could be combined with a daemon type program to issue OS commands, run shell scripts, etc....
    There is a writeup on metalink with examples.
    HTH -- Mark D Powell --

  • How can I execute a  .bat  file from inside a java application

    I have a .bat file which contains an executable file(.exe) and some input and output file names. What commands can I use to execute this bat file from my java application.

    After raeding tkleisas' reply; i am trying to invoke another application (which can be invoked from the command line) by using a batch file and trying Runtime.exec for executing a batch file.
    My current code is:
    Runtime runtime = Runtime.getRuntime();
    Process trialProcess;
    trialProcess = runtime.exec("cmd.exe /C start C:\\guns.bat /B");
    And my guns.bat looks like:
    cd C:\CALPUFF
    echo trial
    start calpuff.exe CALPUFF.INP
    This is not working for me and i get the following in the error stream of the trialProcess:
    Error :
    The system cannot execute the specified program.
    Process finished with exit code 1
    Has anyone come across something like this and know what's wrong with this one??
    thnx

  • Executing a shell script from pl/sql stored procedure

    Hi,
    I have Oracle 8i on HP-UX.
    I am passing a shell script name as a parameter to a user defined function from a pl/sql stored procedure. This user defined function has insterface to a user defined Java class file in Aurora java virtual machine which is written using runtime class which can execute any OS command or any shell script. I am getting any OS command run successfully, but could not run my own shell script. It's is not getting environment variables of my own, so not getting executed. So please suggest how can get these env variables in my shell script and also suggest other sucurity concerns to be taken into consideration.
    If you have any questions please let me know.
    This is really a very urgent issue.....
    Please help me.
    Thanks
    Srinivasa Rao Kolla

    Your best bet is to use the dbms_pipe builtin package to send the command to the host

  • How to call a remote stored proc from a local stored proc using DB Link

    Hi All,
    I am trying to call a stored procedure residing in another data base from the local procedure of my local data base using DB link,I am using the following syntax to call the procedure
    CREATE OR REPLACE PROCEDURE MYLOCALPROCEDURE(Input1 IN varchar2 ,Input2 IN varchar2) IS
    BEGIN
    RemoteStoredprocedurename(Input1,Input2)@DBLINK;
    END;
    END MYLOCALPROCEDURE;
    Its giving a compilation error as @ not expected
    If i try to execute this way
    CREATE OR REPLACE PROCEDURE MYLOCALPROCEDURE(Input1 IN varchar2 ,Input2 IN varchar2) IS
    BEGIN
    RemoteStoredprocedurename(Input1,Input2);
    END;
    END MYLOCALPROCEDURE;
    Its giving an error as stored procedure must be declared.
    A public synonym is created at the Remote database to which DB link is created.
    Can you please let me know on the exact syntax to call the procedure residing in other database through DB Link.
    Thanks in advance,
    Kumar

    Try:
    CREATE OR REPLACE PROCEDURE MYLOCALPROCEDURE(Input1 IN varchar2 ,Input2 IN varchar2) IS
    BEGIN
    RemoteStoredprocedurename@DBLINK(Input1,Input2);
    END;
    END MYLOCALPROCEDURE; Amiel

  • Permission denied when I execute a unix command from inside my Java applet.

    Hi Gang,
    Forgive me if I'm posting this to the wrong forum! I didn't get any answers on the previous forum that I posted this to.
    I've written a simple java applet that runs a unix command and then displays some information. The applet compiles fine, and runs perfectly from the command line on my unix system.
    However, when I point a browser at the applet from my desktop PC I get the following error as taken from the java console:
    Exception in thread "AWT-EventQueue-2" java.security.AccessControlException: access denied (java.io.FilePermission <<ALL FILES>> execute)
    This is of course the first line in a long line of error messages. It appears that I am not able to execute a command on the unix system through my applet. I know the problem is with trying to execute a unix command since commenting it causes no error in the web browser. This is the command I'm using in java to execute the unix command:
    p = Runtime.getRuntime().exec("ps");
    Here's the html file on the unix system:
    <html>
    <head></head>
    <body>
    <appletcode=G.class height="250" width="400">
    Your browser does not support the applet tag.
    </applet>
    </body>
    </html>
    I won't list the java code since it is compiling and working on the command line. But, if you want to see it I'll provide it.
    I've done quite a bit of research on this and it seems that a great number of people have similar problems reading or executing files through java. I have yet to find a solution to this problem.
    Here are some details about my setup:
    Server:
    HP9000 running HP/UX 11.23
    Apache Web Server 2.0.35
    Java 1.5
    Desktop PC:
    Win2K Pro
    Internet Explorer 6
    Java 1.6
    If you have a solution I would be very grateful! This problem is keeping me from writing my application!
    thanks!
    kev

    Multi-posted.
    Already answered here http://forum.java.sun.com/thread.jspa?threadID=5225314&messageID=9916327#9916327

  • Creating a table/view or temporary table from within a stored procedure

    Hi Gurus,
    Can someone tell me if it is possible to create a table (or view) from within a stored procedure.
    PROBLEM:
    In fact I need to create a report at back end (without using oracle developer forms or reports). This report requires creating several tables to hold temporary report data. If I create a sql*plus script for this, i works fine, because it can run DDL and other sql or pl/sql statements sequencialy. But this sql*plus script cannot be called from application. So, application needs an stored procedure to do this task and then application call that procedure. But within stored procedure, i am unable to create table (or run any ddl statement). Can somebody help me in this?
    Thanks in Advance.

    Denis,
    The problem with Nicholas' suggestion isrelated to the fact that now you have two components
    (a table and a stored procedure)
    I don't see any problem to have "two
    components" here. After all, what about all others
    tabes ? This is only one more, but I don't understand
    why want manage less objects, that implies more code,
    more maintenance, and more difficulties to debug.
    Needless to say about performance...
    Nicolas.The same reasons apply if you were forced to declare all PL/SQL variables publicly (outside the stored proc.) rather than privately (from inside the stored proc). Naming conflicts for one. If the name that you want to use for the GTT already exists, you need to find a new name. With the SQL Server type local/private declarations, you wouldn't have that problem.
    I can see how performance would be the same or better using GTTs. If the number of records involved is low, this is likely negligable.

  • Execute binary from inside the app?

    Hello! I'm working on a Mac App that on the push of a button, will execute a binary file from inside the .app file. But I don't know where to place the binary so i can access it, and how to execute it.
    Thanks,
    Andrei

    Hello,
         We are able to use the Java Gui directly from the mac without any problems.
    We are recieving the following error from the Mac Console when we execute the Iview from with the portal.
    5/1/08 1:17:35 PM [0x0-0x5d05d].org.mozilla.firefox[656] ### MRJPlugin:  getPluginBundle() here. ###
    5/1/08 1:17:35 PM [0x0-0x5d05d].org.mozilla.firefox[656] ### MRJPlugin:  CFBundleGetBundleWithIdentifier() succeeded. ###
    5/1/08 1:17:35 PM [0x0-0x5d05d].org.mozilla.firefox[656] ### MRJPlugin:  CFURLGetFSRef() succeeded. ###
    5/1/08 1:17:35 PM [0x0-0x5d05d].org.mozilla.firefox[656] _NSJVMLoadLibrary: NSAddLibrary failed for /System/Library/Frameworks/JavaVM.framework/Versions/(null)/Libraries/libjvm.dylib
    5/1/08 1:17:35 PM [0x0-0x5d05d].org.mozilla.firefox[656] JavaVM FATAL: Failed to load the jvm library.
    Were the (null) is located in the error log above we presently have version 1.4.1, 1.4.2, 1.5.0, 1.6.0.   So it looks as if it isn't getting the version of java from the Transaction_configuration file that it should be pointed to.
    Any suggestions.

  • How to execute a HANA stored proc from Data Services

    Hi
    How do i execute a HANA stored procedure from Data Services.
    in the HANA SQL editor , we run the stored procedure "name_of_sp" as
    call name_of_sp ();
    call name_of_sp ( 1 , 2 ) // suppose 1 and 2 are two integer input parameters.
    so how do I call the above from Data Services .
    SQL('name_of_datastore', 'call name_of_sp()') does not seem to work , ,
    Rishi

    I got the answer , we dont need to import sp .
    i was just having a syntax error:
    the statement below works
    SQL('name_of_datastore', 'call name_of_sp()');

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

  • Calling DB2 Stored Proc from Oracle DB

    Hi,
    I am having two different database running (One is oracle on solaris while the other one is db2 on os/390 mainframe) i want to pass the data realtime. Is there any way I can call a DB2 stored procedure from oracle directly. If anyboy can help in this will be really helpful.
    thanks,
    Kishor

    odi version we have is  ODI_11.1.1.6.0, it is not migrated and 'Always Execute' option is checked already.
    tried using variables in capital format but did not worked,
    begin
    schema_name.proc_name(#LV_TABLE_NAME,#LV_SCHEMA_NAME,#LV_START_DATE,#LV_END_DATE);
    end;
    odi is giving error if it finds any bug in stored proc but after fixing its completing successfully without errors in operator but i am not able to see the result.
    Please advise.

  • Calling a COBOL stored proc from Java Servlet

    I am trying to call a COBOL stored proc from a Java Servlet. The stored proc is stored on a DB2 database. I need to send 6 inputs to the COBOL stored proc and the output will be the return code of the stored proc. I'm not sure if I'm going about this the right way. This is how my code looks...
    public int callStoredProc(CallableStatement cstmt,
    Connection con,
    String sYear,
    String sReportNbr,
    String sSystemCode,
    String sUserId,
    String sModuleNbr,
    String sFormId){
    int iParm1 = 0;
    try{
    Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
    catch(ClassNotFoundException ex){
    System.out.println("Failed to locate database driver: "
    + ex.toString());
    return iParm1;
    try{
    cstmt = con.prepareCall("{? = CALL MKTPZ90C
    cstmt.registerOutParameter(1, Types.INTEGER);
    cstmt.setString(2, sYear);
    cstmt.setString(3, sReportNbr);
    cstmt.setString(4, sSystemCode);
    cstmt.setString(5, sUserId);
    cstmt.setString(6, sModuleNbr);
    cstmt.setString(7, sFormId);
    cstmt.execute();
    iParm1 = cstmt.getInt(1);
    CloseSQLStatement(cstmt);
    catch(SQLException ex) {
    CloseSQLStatement(cstmt);
    System.out.println("SQL exception occurred:" +
    ex.toString());
    return iParm1;
    return iParm1;
    Could someone tell me if this is the right way to go about doing this?
    Thanks!!!!!!

    I didn't see the code where you create the database connection (variable "con"). However, the answer to your question "Is this the right way...", for me, is "Anything that works is the right way." So try it. That's a first approximation, but once you have something that works you can start on improving it, if that becomes necessary.

  • Execute APEX stored procedure from outside APEX

    I am looking at developing an application in APEX, but there needs to be a batch component that I would like to call from our corporation's scheduler. Is there a way for me to call an APEX stored procedure from a 3rd party scheduling software?
    We use this method on all other oracle databases here, but are new to using APEX.
    Thank you,
    Trevor

    This applicaiton is for the internal administration of an External database.
    So there is an external web application that will have a user sign in, and request some transactions. These requests need to be brought inside our firewall to the APEX tables, where our admin staff will access the requests via this internal administrative applicaiton. It will tie into our Customer Information System, giving our staff all the data they need in one application. Requested transactions, and customer information. Once processed, the status of each transaction will be pushed back out to the external database for our customers to view.
    The transfer of data, along with some other logic, is written in PL/SQL stored procs. To keep within our devlopement guidleines, I would like to kick them off using our existing scheduler. That way I only have one internal database to worry about.

Maybe you are looking for

  • Overclocking an i7-2700k on P67A-GD65

    My specs are: Intel Core i7-2700K @ stock speeds (Cooled by Hyper 212 Plus) MSI P67A-GD65 (B3) G.SKILL Ripjaws Series 16GB DDR3 1600 Crucial M4 128GB SATA III 2x 2TB Samsung Spinpoint F4 (Storage) ATI Radeon 4870x2 Samsung Blue-Ray Combo/DVD Burner C

  • 10.6.8 released

    for OSX and Server : 10.6.8. includes Updates to IPv6, AppStore , Security and general bugfixes. Recommended for all users to install and especially for Lion Upgraders as it prepares Snow Leopard for that. Download here ( or via Software Update ) : h

  • How do i make is so that the program is running already and then have a start button to execute?

    I created a program to control a function generator.  I want it so that the program is already running when i load it up, and then when i actually want it to run press a start button.   I think you can just do a case structure for the start button...

  • Vendor Return Excise entry

    Hi All, Can any body let me know the Excise accounting Entry of Vendor Return (Movt. 122/161)? In my case it is displaying; Credit ---> BED, ECS & HEC Debit  ---> PLA on hold and Which ETT system will use? With Reagrds Manoj Singh

  • Double redirect instead of single why?

    Hi everybody , when one of my forms is posted in my web application it calls the same action twice ( using command pattern). so the command is 'send-to-update' this gets done and processing continues. After processing I forward to another jsp. This d