pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedUser function that returns a set of rows.
2+ messages / 2 participants
[nested] [flat]
* User function that returns a set of rows.
@ 2010-05-24 18:33 David Harel <hareldvd@gmail.com>
0 siblings, 1 reply; 2+ messages in thread
From: David Harel @ 2010-05-24 18:33 UTC (permalink / raw)
To: pgsql-sql
Hi,
I'm struggling to write what seed at the time a simple function
like:
"CREATE FUNCTION foo() RETURNS IDONO as
$$
select * from tbl;
return (whatever that will give the *);
$$
up till now I got this far:
CREATE OR REPLACE FUNCTION select_business_types ()
RETURNS SETOF RECORD
AS
$body$
DECLARE
rec RECORD;
-- fields business_type_id business_type_name
BEGIN
FOR
rec IN SELECT * FROM sv_bo_business_types
LOOP
RETURN NEXT rec;
END LOOP;
RETURN;
END;
$body$
LANGUAGE 'plpgsql';
When I tried it from the shell I got a nasty error message about that I
am not in an environment to receive a set ??? (can't see it now. Office
restrictions).
Any idea?
--
Regards.
David Harel,
==================================
Home office +972 77 7657645
Cellular: +972 54 4534502
Snail Mail: Amuka
D.N Merom Hagalil
13802
Israel
Email: hareldvd@ergolight-sw.com
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: User function that returns a set of rows.
@ 2010-05-24 22:14 Joshua Tolley <eggyknap@gmail.com>
parent: David Harel <hareldvd@gmail.com>
0 siblings, 0 replies; 2+ messages in thread
From: Joshua Tolley @ 2010-05-24 22:14 UTC (permalink / raw)
To: David Harel <hareldvd@gmail.com>; +Cc: pgsql-sql
On Mon, May 24, 2010 at 09:33:35PM +0300, David Harel wrote:
> When I tried it from the shell I got a nasty error message about that I am
> not in an environment to receive a set ??? (can't see it now. Office
> restrictions).
>
> Any idea?
Your query should say something like "SELECT * FROM select_business_types()".
You'll get that error if you instead say "SELECT select_business_types()".
--
Joshua Tolley / eggyknap
End Point Corporation
http://www.endpoint.com
Attachments:
[application/pgp-signature] signature.asc (196B, ../../4bfafa57.0752640a.0b22.ffff88ac@mx.google.com/2-signature.asc)
download
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2010-05-24 22:14 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-05-24 18:33 User function that returns a set of rows. David Harel <hareldvd@gmail.com>
2010-05-24 22:14 ` Joshua Tolley <eggyknap@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox