From: Stewart Ben (RBAU/EQS4) * <Ben.Stewart@au.bosch.com>
To: pgsql-sql@postgresql.org
Subject: Re: Question about functions
Date: Mon, 17 Oct 2005 14:41:21 +1000
Message-ID: <E253BDD7F008244585AEE87AF8F0224F116C7AE2@cl-mail01.au.bosch.com> (raw)
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.stewart@au.bosch.com
http://www.bosch.com.au/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: Ben.Stewart@au.bosch.com
Subject: Re: Question about functions
In-Reply-To: <E253BDD7F008244585AEE87AF8F0224F116C7AE2@cl-mail01.au.bosch.com>
References: <E253BDD7F008244585AEE87AF8F0224F116C7AE2@cl-mail01.au.bosch.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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