From: | <slapo(at)centrum(dot)sk> |
---|---|
To: | <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: Function working in PostgreSQL 8.3.6 and not in 7.4.8 |
Date: | 2009-04-11 21:30:50 |
Message-ID: | 200904112330.12424@centrum.cz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Thanks, that was it indeed :D
I found it in the documentation only after your post.
Here's the modified function working with 7.4.8, in case somebody would like to know:
CREATE OR REPLACE FUNCTION subcategories(int) RETURNS setof int AS '
DECLARE
-- declarations
category ALIAS FOR $1;
category_current record;
sub_category_current record;
BEGIN
-- function body
SELECT category as my_output INTO category_current;
RETURN NEXT category_current.my_output;
FOR category_current IN SELECT id FROM is_categories WHERE id_parent=category AND status=''1'' LOOP
FOR sub_category_current IN SELECT subcategories FROM subcategories(category_current.id) LOOP
RETURN NEXT sub_category_current.subcategories;
END LOOP;
END LOOP;
RETURN;
END;
' LANGUAGE plpgsql;
Thanks again :)
Regards,
Peter Slapansky
______________________________________________________________
> Od: tgl(at)sss(dot)pgh(dot)pa(dot)us
> Komu: slapo(at)centrum(dot)sk
> CC: pgsql-novice(at)postgresql(dot)org
> Datum: 11.04.2009 22:57
> Předmět: Re: [NOVICE] Function working in PostgreSQL 8.3.6 and not in 7.4.8
>
><slapo(at)centrum(dot)sk> writes:
>> It's my second function in pg/plsql I've created and I don't really know why there are no results being returned in 7.4.8.
>
>RETURN QUERY doesn't exist in 7.4, and unfortunately the syntax checking
>in that ancient version isn't very tight. In a function returning set,
>it just ignores anything after RETURN unless it's RETURN NEXT. So it
>just sees a RETURN command telling it to exit.
>
> regards, tom lane
>
From | Date | Subject | |
---|---|---|---|
Next Message | Radcon Entec | 2009-04-13 12:44:28 | Turning off row counting in PG Admin |
Previous Message | Tom Lane | 2009-04-11 20:57:22 | Re: Function working in PostgreSQL 8.3.6 and not in 7.4.8 |