diff options
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/plperl.sgml | 14 | ||||
-rw-r--r-- | doc/src/sgml/plpgsql.sgml | 16 | ||||
-rw-r--r-- | doc/src/sgml/plpython.sgml | 11 | ||||
-rw-r--r-- | doc/src/sgml/pltcl.sgml | 12 | ||||
-rw-r--r-- | doc/src/sgml/ref/call.sgml | 4 | ||||
-rw-r--r-- | doc/src/sgml/ref/create_procedure.sgml | 7 |
6 files changed, 62 insertions, 2 deletions
diff --git a/doc/src/sgml/plperl.sgml b/doc/src/sgml/plperl.sgml index cff7a847dee..518a86459ad 100644 --- a/doc/src/sgml/plperl.sgml +++ b/doc/src/sgml/plperl.sgml @@ -279,6 +279,20 @@ SELECT * FROM perl_row(); </para> <para> + Similarly, output arguments of procedures can be returned as a hash + reference: + +<programlisting> +CREATE PROCEDURE perl_triple(INOUT a integer, INOUT b integer) AS $$ + my ($a, $b) = @_; + return {a => $a * 3, b => $b * 3}; +$$ LANGUAGE plperl; + +CALL perl_triple(5, 10); +</programlisting> + </para> + + <para> PL/Perl functions can also return sets of either scalar or composite types. Usually you'll want to return rows one at a time, both to speed up startup time and to keep from queuing up diff --git a/doc/src/sgml/plpgsql.sgml b/doc/src/sgml/plpgsql.sgml index c1e3c6a19d8..6c25116538a 100644 --- a/doc/src/sgml/plpgsql.sgml +++ b/doc/src/sgml/plpgsql.sgml @@ -1870,6 +1870,22 @@ SELECT * FROM get_available_flightid(CURRENT_DATE); then <symbol>NULL</symbol> must be returned. Returning any other value will result in an error. </para> + + <para> + If a procedure has output parameters, then the output values can be + assigned to the parameters as if they were variables. For example: +<programlisting> +CREATE PROCEDURE triple(INOUT x int) +LANGUAGE plpgsql +AS $$ +BEGIN + x := x * 3; +END; +$$; + +CALL triple(5); +</programlisting> + </para> </sect2> <sect2 id="plpgsql-conditionals"> diff --git a/doc/src/sgml/plpython.sgml b/doc/src/sgml/plpython.sgml index ba79beb7437..3b7974690ed 100644 --- a/doc/src/sgml/plpython.sgml +++ b/doc/src/sgml/plpython.sgml @@ -651,6 +651,17 @@ $$ LANGUAGE plpythonu; SELECT * FROM multiout_simple(); </programlisting> </para> + + <para> + Output parameters of procedures are passed back the same way. For example: +<programlisting> +CREATE PROCEDURE python_triple(INOUT a integer, INOUT b integer) AS $$ +return (a * 3, b * 3) +$$ LANGUAGE plpythonu; + +CALL python_triple(5, 10); +</programlisting> + </para> </sect2> <sect2> diff --git a/doc/src/sgml/pltcl.sgml b/doc/src/sgml/pltcl.sgml index a834ab8862b..01f6207d363 100644 --- a/doc/src/sgml/pltcl.sgml +++ b/doc/src/sgml/pltcl.sgml @@ -186,6 +186,18 @@ $$ LANGUAGE pltcl; </programlisting> </para> + <para> + Output arguments of procedures are returned in the same way, for example: + +<programlisting> +CREATE PROCEDURE tcl_triple(INOUT a integer, INOUT b integer) AS $$ + return [list a [expr {$1 * 3}] b [expr {$2 * 3}]] +$$ LANGUAGE pltcl; + +CALL tcl_triple(5, 10); +</programlisting> + </para> + <tip> <para> The result list can be made from an array representation of the diff --git a/doc/src/sgml/ref/call.sgml b/doc/src/sgml/ref/call.sgml index d45e3ec22e9..7418e19eeba 100644 --- a/doc/src/sgml/ref/call.sgml +++ b/doc/src/sgml/ref/call.sgml @@ -31,6 +31,10 @@ CALL <replaceable class="parameter">name</replaceable> ( [ <replaceable class="p <para> <command>CALL</command> executes a procedure. </para> + + <para> + If the procedure has output arguments, then a result row will be returned. + </para> </refsect1> <refsect1> diff --git a/doc/src/sgml/ref/create_procedure.sgml b/doc/src/sgml/ref/create_procedure.sgml index bbf8b03d04e..f3c3bb006cf 100644 --- a/doc/src/sgml/ref/create_procedure.sgml +++ b/doc/src/sgml/ref/create_procedure.sgml @@ -96,8 +96,11 @@ CREATE [ OR REPLACE ] PROCEDURE <listitem> <para> - The mode of an argument: <literal>IN</literal> or <literal>VARIADIC</literal>. - If omitted, the default is <literal>IN</literal>. + The mode of an argument: <literal>IN</literal>, + <literal>INOUT</literal>, or <literal>VARIADIC</literal>. If omitted, + the default is <literal>IN</literal>. (<literal>OUT</literal> + arguments are currently not supported for procedures. Use + <literal>INOUT</literal> instead.) </para> </listitem> </varlistentry> |