Calling another PL/SQL procedure within a procedure

回眸只為那壹抹淺笑 提交于 2019-12-02 23:51:16

问题


I'm new to PL/SQL & would greatly appreciate help in this. I've created a procedure to copy contracts. Now I want to call another procedure from within this procedure which shall copy all the programs related to the contract I'm copying. One contract can have multiple programs.


回答1:


You cal call another procedure in another package by using PackageName.ProcedureName(vcParameters => 'InputParameter1');

If the procedure is in the same package you could do it without the PackageName, so just ProcedureName(vcParameters => 'InputParameter1');




回答2:


You call a procedure by simply putting its name and parameters in your code, e.g.

begin
    dbms_output.put_line('Demo');
end;

or within a procedure,

create or replace procedure demo
as
begin
    dbms_output.put_line('Demo');
end;

I have used dbms_output.put_line as an example of a procedure, but obviously any other procedure would be called the same way:

begin
    foo;
    bar(1);
    demo(true, 'Bananas', date '2018-01-01');
end;

For some reason, many beginners are tempted to add exec before the procedure call. I don't know where that comes from because PL/SQL has no such keyword. Possibly they are thinking of the SQL*Plus execute command, which can be abbreviated to exec. However, SQL*Plus is a separate command line utility with its own commands that have nothing to do with the PL/SQL language.



来源:https://stackoverflow.com/questions/38842882/calling-another-pl-sql-procedure-within-a-procedure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!