Re: Functions that return both Output Parameters and recordsets - Mailing list pgsql-general

From Pavel Stehule
Subject Re: Functions that return both Output Parameters and recordsets
Date
Msg-id 162867790706110513g1eb821ebr46a35e1f43cc1503@mail.gmail.com
Whole thread Raw
In response to Functions that return both Output Parameters and recordsets  (Jeremy Nix <Jeremy.Nix@sfsltd.com>)
Responses Re: Functions that return both Output Parameters and recordsets  (Jeremy Nix <Jeremy.Nix@sfsltd.com>)
List pgsql-general
Hello

it's possible, but it's probably some different than you expect


CREATE OR REPLACE FUNCTION foo(OUT a integer, OUT b integer)
RETURNS SETOF RECORD AS $$
BEGIN
  a := 10; b := 10;
  RETURN NEXT;
  a := 11; b := 20;
  RETURN NEXT;
  RETURN;
END;
$$ LANGUAGE plpgsql;

postgres=# select * from foo();
 a  | b
----+----
 10 | 10
 11 | 20
(2 rows)

Regards
Pavel Stehule


2007/6/11, Jeremy Nix <Jeremy.Nix@sfsltd.com>:
> Is this possible?  I'm attempting to create a function like this and I'm
> getting the following error:
>
> ERROR: RETURN NEXT cannot have a parameter in function with OUT
> parameters at or near "myRecord".
>
> --
>
> __________________________________
> Jeremy Nix
> Senior Application Developer
> Southwest Financial Services, Ltd.
> (513) 621-6699
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faq
>

pgsql-general by date:

Previous
From: "Pavel Stehule"
Date:
Subject: Re: transaction problem using cursors
Next
From: Jeremy Nix
Date:
Subject: Re: Functions that return both Output Parameters and recordsets