Q

How to call a procedure in a procedure

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

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 last published in January 2008

Dig Deeper on Oracle database administration

PRO+

Content

Find more PRO+ content and other member only offers, here.

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.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close