Calling another procedure in a procedure

How can we execute procedure in another procedure?

Try running following code
create or replace procedure child is
begin
dbms_output.put_line('This text from Child');
end;
create or replace procedure parent is
begin
child;
end;
exec parent;
null

Similar Messages

  • In SQLScript, how to use EXEC to call another procedure with parameters in procedure?

    Hi experts,
    In SQLScript, How to use EXEC to call another procedure with input and output parameters in procedure?thanks very much

    Hi Sagar,
    thank you! I generate another procedure with an input parameter and an output parameter in a procedure. Then i need to call the generated procedure using EXEC. Here is my code:
    create procedure ftest1(out sum_num bigint)
    as
    begin
    declare fa_output bigint;
    declare v_sql_drop varchar(200);
    declare v_sql varchar(500);
    declare cursor c_cursor1 for select num from TABLE1;
    --v_sql_drop := 'drop procedure fe';
    --exec v_sql_drop;
    v_sql := 'create procedure fe(in i_num bigint,out o_num bigint) as begin';
    v_sql := :v_sql || ' o_num := :i_num * 2 + :i_num * :i_num;';
    v_sql := :v_sql || ' end';
    exec v_sql;
    open c_cursor1;
    for c_item as c_cursor1 do
    exec 'call fe(c_item.num,o_num=>fa_output)';
    if sum_num is null then
    sum_num := fa_output;
    else
    sum_num := :sum_num + fa_output;
    end if;
    end for;
    close c_cursor1;
    end;
    The underline code is using exec to call the generated procedure. But this method cannot work. Any suggestion? thanks again!

  • Is it possible to calling another stored procedure in another database?

    Hello all, I hope you can help me out.
    I need to call another stored procedure in another database? Is it possible?
    I know you can call another stored procedure in the same package:
    Var_SQL :='call SP_Tes (''' || Var_1 || ''',''' || Var_2 ||''')' ;
    EXECUTE IMMEDIATE Var_SQL;
    But how do call it if its in another database? I assume, I'd have to open a new connection to it, then call it...
    Please help me. thanks

    I managed to find my synonym;
    select synonym_name, table_owner, table_name from all_synonyms where synonym_name = 'PKG_EDONWEB70'
    (BTW, its upper case sensitive, I eventually found out)
    But as you said; "anyway, what..."
    1)Crete synonym with the dblink, which is the same DB as the one I'm using:chec
    create public synonym pkg_edonweb70test2 for [email protected]
    Result: ok2)check it exists:
    select synonym_name, table_owner, table_name from all_synonyms where synonym_name = 'PKG_EDONWEB70TEST2'
    Result: ok3)check it runs in sql:
    DECLARE
        P_RETURNVALUE1 number;
    BEGIN
        PKG_EDONWEB70TEST2.SP_TESTSMB_DESTINATION ( P_RETURNVALUE1 );   
        COMMIT;
    END;
    Result: ok4)Add it to the strored procedure that is going to call it
    PROCEDURE sp_testSMB_origin(P_RETURNVALUE1 OUT number) IS
            thissql varchar(1000);      
        BEGIN
        BEGIN
            PKG_EDONWEB70TEST2.SP_TESTSMB_DESTINATION ( P_RETURNVALUE1 );   
            COMMIT;
        END;
        end sp_testSMB_origin;
    Result: FAIL; pls-00201: identifier 'PKG_EDONWEB70TEST2' must be declared

  • Writing a simple procedure to call another procedure

    Greetings,
    im pretty new to pl/sql and just recently started playing around with it, I was wondering howi would go about creating a basic skeleton of procedure that would call another procedure.
    function testfunction is the function I wish to call and accepts 3 params, it then returns a pl/sql table which contains all the rows I want. I then want to populate a table with this data. Do I need to create a loop within the procedure to populate the table or can I use a function of some sort to just directly insert the entire pl/sql table into the actual table?

    Thankyou both for the follow ups! I may have to go with the loop method but before I dive into that I was reading about the merge function and feel as though it would do what I need perfectly (I just need to append data to a table)
    So I came up with something like this
    PROCEDURE test_procedure
    IS
    BEGIN
    MERGE INTO test_table
    USING (test_package.test_function(123, 456, 789))
    WHEN MATCHED THEN UPDATE SET FIELDA = resulta, FIELDB = resultb, FIELDC = resultc
    WHEN NOT MATCHED THEN INSERT (FIELDA, FIELDB, FIELDC) VALUES (resulta, resultb, resultc)
    END test_procedure;
    This seems like it would work great, the resulta, resultb, and resultc are all returned from the function but im not sure exactally about that being the correct way to call it. I will go read up on this approach but fall back on the looping if it doesnt work out, thankyou everyone =D

  • Dynamically call another procedure

    In SQLServer you can have a variable that holds a procedure
    name. The variable can then be used in the execute statement.
    Is there any way in PLSQL to dynamicaly call another procedure.
    example:
    begin
    declare procname varchar2(32) = 'proc1';
    --now call the procedure
    procname -- ?
    execute immediate procname -- ?
    end;
    Thanks,
    Dermot.

    Just wrap it in an anonymous block:
    create or replace procwrap
    (p_procname in varchar2)
    is
    begin
    execute immediate 'begin ' || p_procname || '; end;';
    end;

  • Need to write a plsql block for calling another procedure.

    Hi Guys,
    I have a requirement to write a plsql block and to call another procedure which is having 5 parameters (each parameter having multiple values). Calling procedure generates one SQL query and it needs to be generated all combinations and print in another table.
    I need to pass multiple values for first three parameters from my PLSQL block and run.
    call sample proc:
    procedure(
    param1 varchar2,
    param2 p_varchar2,
    param3 p_varchar2,
    param4 in varchar2,
    param5 in number
    is
    begin
    ls_sql_query := 'with client_query as (select * from table)';
    end;
    Thanks in advance!
    Rgds,
    LRK

    This article is on exactly your subject. It is worth a careful read.
    Ask Tom: On Popularity and Natural Selection
    I paraphrase: "Always code a reference to every possible bind variable but do so in such a way that the optimizer removes the bind variable for us if we aren't going to actually use it in that particular execution of the SQL statement."
    P.S. This is the same answer I gave when you asked the same question earlier.

  • Can crystal allow to call procedure from a procedure?

    Hi,
    Currently I am using crystal to call a procedure. The procedure will call another procedure by doing some insert statement in the second procedure. I heard that this could not be work, is that true? Is there any other way to do?

    here is an example of a procedure calling another procedure to do the insert:
    SQL> create table test_tab
      2  (id number);
    Table created.
    SQL> create or replace procedure procedure_1 as
      2  begin
      3    insert into test_tab
      4    select nvl(max(id),0)+1 from test_tab;
      5  end;
      6  /
    Procedure created.
    SQL> create or replace procedure procedure_2 as
      2  begin
      3    -- now we call the other procedure
      4    procedure_1;
      5    commit;
      6  end;
      7  /
    Procedure created.
    SQL> execute procedure_2;
    PL/SQL procedure successfully completed.
    SQL> select * from test_tab;
            ID
             1
    SQL> execute procedure_2;
    PL/SQL procedure successfully completed.
    SQL> select * from test_tab;
            ID
             1
             2

  • Urgent : while calling a pl/sql stored procedure I am getting this error.

    Error iam getting like this:
    IDALException: ORA-06550: line 1, column 7: PLS-00201: identifier 'BORGPURCHASEDELEGATION_SEL' must be declared ORA-06550: line 1, column 7: PL/SQL: Statement ignored [ com.commerceone.ebs.infra.dal.idal.BasicSQL.oracleExceptionHandler(BasicSQL.java:863)]
    ADALException: Default Message[ com.commerceone.ebs.infra.dal.adal.Adal.execute(Adal.java:765)]
    ADALException: Default Message[ com.commerceone.ebs.infra.dal.adal.Adal.executeEbo(Adal.java:605)]
    BusinessFatalException: Default Message[ com.commerceone.ebs.wf.business.PurchaseBorgDelegation.getData(PurchaseBorgDelegation.java:483)]
    CommandException: Default Message[ com.commerceone.ebs.apps.profile.command.UserProfilePurchaseDelegationSaveCmd.execute(UserProfilePurchaseDelegationSaveCmd.java:124)]
    ActionException: Default Message[ com.commerceone.ebs.apps.base.action.ActionImpl.executeCommand(ActionImpl.java:107)]
    JobException: Default Message[ com.commerceone.ebs.apps.ui.WebJobImpl.executeAction(WebJobImpl.java:115)]
    JobException: Default Message[ com.commerceone.ebs.apps.ui.BuyerJob.executeAction(BuyerJob.java:750)]
    JobException: Default Message[ com.commerceone.ebs.apps.ui.BuyerJobWrapper.run(BuyerJobWrapper.java:64)]
    Thanks
    raji

    This has happened to me when I do not have the proper grants and/or synonyms set up. My JDev/J2EE connection user does not own the database objects so I need to grant access to the database object owner's database account and create synonyms available to the connection user's database account. If you are using the same database account in your JDev/J2EE connection object as you are using to run the stored proc in SQL*Plus, this is not your problem.
    I would test each part of the database involvement. For example, if you create a database view (with no additional grants or synonyms) in the user account that owns that stored procedure, can you create an ADF BC view object from that view in JDev and can you run the BC tester in JDev on it? If so, the connection user and object owner user accounts are probably the same.
    Another thing to try is, instead of executing the stored procedure, do something like this:
    stmt = "DECLARE v_dummy; BEGIN SELECT 1 INTO v_dummy FROM dual; END;";If that works, your calling mechanism for the stored procedure works.

  • Calling Procedure B from Procedure A having parameters

    Hi,
    I have two procedures, I m registering first procedure as a concurrent program  like  XXXpackage.main
    I want to call Procudure new_segments_id from Procedure main.
    I need l_old_id  parameter for new_segments_id procedure, so I m passing to main procedure.
    Now, how should i call new_segments_id procedure from main procedure.
    Procedure main(
                           errbuf       OUT VARCHAR2
                          ,retcode    OUT VARCHAR2
                          ,l_old_id    IN  NUMBER
    Procudure new_segments_id(l_old_id    IN  NUMBER
                                             ,l_new_id   OUT NUMBER
    Thanks.

    Not sure if this is what exactly you want but below is an example of propagation of OUT parameters of one procedure as IN parameters to the another procedure within the same package.
    SQL> CREATE OR REPLACE
      2  PACKAGE PACKAGE_TEST
      3  AS
      4    PROCEDURE procedure_1(
      5        out_ename OUT VARCHAR2);
      6    PROCEDURE procedure_2(
      7        v_ename VARCHAR2);
      8  END PACKAGE_TEST;
      9  /
    Package created.
    SQL> CREATE OR REPLACE
      2  PACKAGE body package_test
      3  IS
      4  PROCEDURE procedure_1(
      5      out_ename OUT VARCHAR2)
      6  AS
      7    v_ename VARCHAR2(200) := 'SMITH' ;
      8  BEGIN
      9    SELECT
    10      ename
    11    INTO
    12      out_ename
    13    FROM
    14      emp
    15    WHERE
    16      ename = v_ename;
    17    DBMS_OUTPUT.PUT_LINE('PROCEDURE 1');
    18    procedure_2(out_ename);
    19  END;
    20
    21  PROCEDURE procedure_2(
    22      v_ename VARCHAR2)
    23  IS
    24  v_count number;
    25  BEGIN
    26    DBMS_OUTPUT.PUT_LINE('PROCEDURE 2');
    27    dbms_output.put_line(V_ENAME);
    28    select count(*) into v_count from emp where ename = v_ename;
    29    dbms_output.put_line('COUNT is ' || v_count);
    30  END;
    31  END;
    32
    33  /
    Package body created.
    SQL> DECLARE
      2    ENAME VARCHAR2(5);
      3  BEGIN
      4    package_test.procedure_1(ENAME);
      5  END;
      6  /
    PROCEDURE 1                                                                   
    PROCEDURE 2                                                                   
    SMITH                                                                         
    COUNT is 1                                                                    
    PL/SQL procedure successfully completed.
    Ishan.

  • Calling SQL * LOADER  in stored procedure

    Hi Experts,
    Can we call sql*loader in stored procedures? . If yes , please let me know the syntax.
    Any help will be highly appreciated.
    Thanks.

    You can also use dbms_schedular to execute any shell or batch file - i guess ->
    BEGIN
      -- UNIX
      DBMS_SCHEDULER.create_job(
        job_name             => 'unix_command_job',
        job_type             => 'EXECUTABLE',
        number_of_arguments  => 1,
        job_action           => '/bin/ls',
        auto_drop            => FALSE,
        enabled              => FALSE);
      DBMS_SCHEDULER.set_job_argument_value('unix_command_job',1,'/tmp');
      DBMS_SCHEDULER.set_attribute('unix_command_job', 'credential_name', 'TIM_HALL_CREDENTIAL');
      DBMS_SCHEDULER.set_attribute('unix_command_job', 'destination', 'marge.localdomain:65001');
      DBMS_SCHEDULER.enable('unix_command_job');
    END;For details ->
    http://www.oracle-base.com/articles/11g/SchedulerEnhancements_11gR1.php
    http://www.oradev.com/dbms_scheduler.jsp
    http://www.psoug.org/reference/dbms_scheduler.html
    Regards.
    Satyaki De.

  • How to call sqlldr utility in stored procedure

    Hi,
    i want to call sqlldr exe from stored procedure.
    Regards,
    Tushar Josih

    user12044491 wrote:
    currently i am working on oracle release 10g R2.
    i am not very much sure whether all CTL option are available in the external table.Before you decide on the method you should clearly understand the following. SQL*Loader is client side tool while job and external table are server side tools. Therefore, unless you are connecting to oracle from database server or file you are loading is accessible from database server, neither job nor external table will help you. And now back to your question - yes, not all SQL*Loader features are available for external tables but most of the time there is a way around it.
    SY.

  • How to call PL-SQL script/stored procedure from Java?

    Assume I want to call a PL-SQL stored procedure from external Java program.
    How can I do this?
    Is there a simple "Hello world" example for this?
    Peter

    This forum is for Oracle only not for java
    Ug

  • How to call PL-SQL script/stored procedure from BPEL?

    Assume I want to call a PL-SQL stored procedure from BPEL.
    How can I do this?
    Is there a simple "Hello world" example for this?
    Peter

    The database adapter supports calling stored procedures. There is an example called "File2StoredProcedure" that you can use as a reference to get started.

  • Calling a Function inside a procedure

    Can you call a function inside a procedure?...if so....how?

    Not all built-in functions can be used directly in an assignment.
    SQL> CREATE PROCEDURE p (p_val IN VARCHAR2) AS
      2  l_v VARCHAR2(10);
      3  BEGIN
      4     l_v := DECODE(p_val,'YES','TRUE','FALSE');
      5  END;
      6  /
    Warning: Procedure created with compilation errors.
    SQL> show error
    Errors for PROCEDURE P:
    LINE/COL ERROR
    4/4      PL/SQL: Statement ignored
    4/11     PLS-00204: function or pseudo-column 'DECODE' may be used inside
             a SQL statement onlyTTFN
    John

  • Function called by what PL SQL procedure

    Hello.
    I want to see all the callers of a PL SQL function. I know it is called by some PL SQL procedures in a package. How do I see who calls the function?
    Thanks.

    i think you can try this : select * from
    user_dependencies where type = 'FUNCTION' actually, that what should what things are referenced by your function
    and you'd be better off with ALL_DEPENDENCIES, since references can cross schemas.
    select name, type from all_dependencies
    where referenced_owner= 'ME'
    and referenced_name= 'MY_FUNCTION'
    and referenced_type ='FUNCTION'
    this will show what other things are using your function. if it's used by a package, it will not show the exact procedure or function within that package.

  • How to call a sql server stored procedure from oracle

    Hi all,
    Please anybody tell me how to call a sql server stored procedure from oracle.
    I've made an hsodbc connection and i can do insert, update, fetch data in sql server from oracle. But calling SP gives error. when I tried an SP at oracle that has line like
    "dbo"."CreateReceipt"@hsa
    where CreateReceipt is the SP of sql server and hsa is the DSN, it gives the error that "dbo"."CreateReceipt" should be declared.
    my database version is 10g
    Please help me how can i call it... I need to pass some parameters too to the SP
    thanking you

    hi,
    thank you for the response.
    when i call the sp using DBMS_HS_PASSTHROUGH, without parameters it works successfully, but with parameters it gives the following error
    ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
    [Generic Connectivity Using ODBC][Microsoft][ODBC SQL Server Driver]Invalid parameter number[Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index (SQL State: S1093; SQL Code: 0)
    my code is,
    declare
    c INTEGER;
    nr INTEGER;
    begin
    c := DBMS_HS_PASSTHROUGH.OPEN_CURSOR@hsa;
    DBMS_HS_PASSTHROUGH.PARSE@hsa(c, 'Create_Receipt(?,?)');
    DBMS_HS_PASSTHROUGH.BIND_VARIABLE@hsa(c,1,'abc');
    DBMS_HS_PASSTHROUGH.BIND_VARIABLE@hsa(c,2,'xyz');
    nr:=DBMS_HS_PASSTHROUGH.EXECUTE_NON_QUERY@hsa(c);
    DBMS_HS_PASSTHROUGH.CLOSE_CURSOR@hsa(c);
    end;
    Create_Receipt is the sp which requires two parameters.
    please give me a solution
    thanking you
    sreejith

Maybe you are looking for

  • Developer role able to edit a shared report that he did not create

    Hi, It seems like user with "BI Publisher Developer" role is able to edit a report in shared folder that he has access to. Question: How can I create a user who can develop/create/edit his own reports, and have view only access to some shared reports

  • Import or load a new logo from the external system

    Hi all... I want to import or load a new logo from the ext system helps to generate for my ALV report program(for top-of-page)......the one from SE78 is not working for me if i do import or with pre-defined one...... pls revert me on urgent basis....

  • Keep the G4 1.42 or Upgrade

    Comments please on whether to keep or upgrade... I have a G4 1.42 with 512mb ram, 80gig drive, BT, 802.11 and DVD writable drive. eBay market is getting anywhere from $280 to $350 for these systems. The system is slow and I'm sure a memory upgrade to

  • Round up syntax for Formatted Search

    Hi all, I need help on writing the formatted search syntax for below scenario. Discount % = 2 decimal place only Unit Price = 99,376.00 Discount = 30.97% Price After Discount = 68,599.25 I want the Price After Discount to be rounded up to 68,600. Any

  • Can I have two versions of OSX running on same machine?

    Hi - since upgrading from Snow Leopard to Mountain Lion recently I have run into an unexpected problem (though I'm sure there would have been a warning that I missed). Some of my older applications, such as Adobe Creative Suite version 1, no longer r