User function that returns a set of rows.
User function that returns a set of rows.
От:
David Harel <hareldvd@gmail.com>
Дата:
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
Re: User function that returns a set of rows.
От:
Joshua Tolley <eggyknap@gmail.com>
Дата:
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