HiveBrain v1.2.0
Get Started
← Back to all entries
snippetMinor

How to get return value from pl sql procedure and assign it to variable?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
returnsqlvalueproceduregethowandfromvariableassign

Problem

Code:

execute x.procedurename(row.accc_no, row.bill_no, 0, null, row.total_balance, 'A',assgn_scen_site_cv, :assgn_scen_site_cv);


Its my procedure.

How to get return value from this proc and assign it to variable ?

Solution

You can create it like this:

CREATE OR REPLACE PROCEDURE procedurename(param1 NUMBER, param2 varchar(20), returnvalue OUT NUMBER);
IS
BEGIN
    ... your code
END;


And then use it like this:

returnvalue NUMBER;
procedurename(0, 'xxx', returnvalue);
dbms_output.putline(returnvalue);


You can look at CREATE PROCEDURE documentation at Oracle website.

Code Snippets

CREATE OR REPLACE PROCEDURE procedurename(param1 NUMBER, param2 varchar(20), returnvalue OUT NUMBER);
IS
BEGIN
    ... your code
END;
returnvalue NUMBER;
procedurename(0, 'xxx', returnvalue);
dbms_output.putline(returnvalue);

Context

StackExchange Database Administrators Q#123803, answer score: 4

Revisions (0)

No revisions yet.