Q

How to call a procedure in a procedure

A SearchOracle.com reader asks, "How do I call another procedure p2 from p1?"

This Content Component encountered an error
I have a procedure p1. How do I get user values to it at run time? How do I call another procedure p2 from p1?
When you create a procedure, you can declare input/output variables. Take a look at this simple procedure:

CREATE PROCEDURE p1 (x IN NUMBER, y OUT VARCHAR2)
AS 
BEGIN
   DBMS_OUTPUT.PUT_LINE('x='||x);
   y:=x;
   p2(y);
END;
/

In the same procedure above, I can obtain the value of "x" at runtime simply by referring to it in my code. My call to DBMS_OUTPUT.PUT_LINE just references the x variable. Similarly, I assign the value of x to the variable y. Since 'y' is defined as an output variable to the procedure, the calling program can see the changes to this variable.

Calling a procedure in a procedure is as simple as stating the procedure's name and supplying any necessary arguments. In my example above, I call procedure P2 and pass the variable "y" to it.

This was first published in January 2008

Dig deeper on Oracle database administration

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close