When using the CALL statement in Oracle to call a stored procedure or function that contains output parameters, you need to: declare the name and data type of the output parameters. Pass output parameters as parameters in the CALL statement. Use the PUT_LINE function in the DBMS_OUTPUT package to print the value of the output parameter.
How to write output parameters when using the CALL statement to call a procedure in Oracle
In Oracle, you can use The CALL statement calls a stored procedure or function. For stored procedures or functions that have output parameters, the output parameters need to be written correctly to receive the value.
Syntax:
<code class="sql">CALL procedure_name(IN input_parameter, OUT output_parameter);</code>
Where:
procedure_name
is the name of the stored procedure or function to be called. input_parameter
is the input parameter passed to the procedure or function. output_parameter
is the output parameter to receive the output value. Example:
Suppose there is a stored procedure get_employee_name
that accepts an employee ID as an input parameter and returns the employee's name . The stored procedure has an output parameter named emp_name
. The following code demonstrates how to use the CALL statement to call this stored procedure and receive the output value:
<code class="sql">DECLARE emp_id NUMBER := 100; emp_name VARCHAR2(50); BEGIN CALL get_employee_name(emp_id, emp_name); DBMS_OUTPUT.PUT_LINE('Employee Name: ' || emp_name); END;</code>
Steps:
DECLARE
statement to declare output parameters and specify their data type. CALL
statement to call the stored procedure, passing the input parameters and output parameters as parameters. PUT_LINE
function in the DBMS_OUTPUT
package to output the value of the output parameter to the console or in the log. Please note that output parameters must be correctly defined as OUT
parameters in the stored procedure or function. Otherwise, you will receive an error when calling.
The above is the detailed content of How to write the output parameters of the call calling process in Oracle. For more information, please follow other related articles on the PHP Chinese website!