Once I've gotten multiple values back from a plpgsql function,
how do I actually reference those values in another plpgsql
function? I've tried several syntaxes and keep getting errors.
Various attempts are below.
Thanks.
On 2004.09.08 15:59 Joe Conway wrote:
>
> Ah yes, that works too. For the record:
>
> CREATE TYPE returntype AS (a INT, b INT);
> CREATE OR REPLACE FUNCTION return_multiple()
> RETURNS returntype
> LANGUAGE plpgsql
> AS '
> DECLARE
> myvar returntype%rowtype;
> BEGIN
> myvar.a := 1;
> myvar.b := 2;
> RETURN myvar;
> END;
> ';
> SELECT * FROM return_multiple();
> a | b
> ---+---
> 1 | 2
> (1 row)
PostgreSQL 7.3.4 on i386-redhat-linux-gnu, compiled by GCC
i386-redhat-linux-gcc (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
CREATE FUNCTION return_multiple2()
RETURNS returntype
LANGUAGE plpgsql
AS '
DECLARE
myvar returntype%rowtype;
a INT;
b INT;
BEGIN
-- SELECT INTO a, b FROM return_multiple();
SELECT INTO a, b return_multiple();
myvar.a := a;
myvar.b := b;
-- SELECT INTO myvar return_multiple();
RETURN myvar;
END;
';
Karl <kop@meme.com>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein