From: | "Stewart Ben (RBAU/EQS4) *" <Ben(dot)Stewart(at)au(dot)bosch(dot)com> |
---|---|
To: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Question about functions |
Date: | 2005-10-17 04:41:21 |
Message-ID: | E253BDD7F008244585AEE87AF8F0224F116C7AE2@cl-mail01.au.bosch.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Mike,
> I am trying to run this function but the return is not
> correct. If I run the select statement from the psql command
> line it works. My guess is that the WHERE clause could be
> causing the problem. Then again, it may be how I am using
> the FOR loop. The ides column is of type TEXT.
>
> CREATE OR REPLACE FUNCTION sp_description_search(varchar)
> RETURNS varchar AS $$ -- <== Problem is here
> DECLARE
> myrec record;
> BEGIN
> FOR myrec IN SELECT * FROM tblStuff WHERE ides LIKE '%$1%' LOOP
> RETURN NEXT myrec; -- <== Problem is here
> END LOOP;
> RETURN;
> END;
> $$ LANGUAGE 'plpgsql';
You need to declare this as a set-returning function if you're using
RETURN NEXT.
Best regards,
Ben Stewart
--
Robert Bosch (Australia) Pty. Ltd.
Engineering Quality Services, Student Software Engineer (RBAU/EQS4)
Locked Bag 66 - Clayton South, VIC 3169 - AUSTRALIA
mailto:ben(dot)stewart(at)au(dot)bosch(dot)com
http://www.bosch.com.au/
From | Date | Subject | |
---|---|---|---|
Next Message | Sri | 2005-10-17 07:23:04 | Problem while using start transaction ans commit; |
Previous Message | Mike Plemmons | 2005-10-17 03:24:44 | Question about functions |