问题
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