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.

4

2 Answers

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');

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.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy