Difference between IN, OUT, IN OUT parameters in PLSQL

Please tell me what are the differences between the IN, OUT, IN OUT parameters in PL / SQL. And also, how can I return more than one value using the PL / SQL procedure.

+5
source share
1 answer

What are the IN / OUT / INOUT parameters?

These are the parameters that you define as part of the function argument list, which are returned back as part of the result. When you create functions, the arguments by default have IN parameters if they are not explicitly specified (which means they are passed and not returned), so you sometimes see that PgAdmin does something like IN somevariable variabletype when using the function wizard.

INOUT, , , .

SQL OUTPUT -

--SQL returning multiple records
CREATE OR REPLACE FUNCTION fn_sqltestmulti(param_subject varchar, 
  OUT test_id integer, OUT test_stuff text) RETURNS SETOF record
AS $$
  SELECT test_id, test_stuff 
    FROM testtable where test_stuff LIKE $1;
$$
LANGUAGE 'sql' VOLATILE;

--example
SELECT * FROM fn_sqltestmulti('%stuff%');

 --OUTPUT--
 test_id |     test_stuff
---------+--------------------
       1 | this is more stuff
       2 | this is new stuff

+5

All Articles