X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4ECB3DA6EE for ; Mon, 17 Oct 2005 01:41:30 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 26356-03 for ; Mon, 17 Oct 2005 04:41:27 +0000 (GMT) Received: from smtp-v.fe.bosch.de (smtp-v.fe.bosch.de [139.15.237.2]) by svr1.postgresql.org (Postfix) with ESMTP id 6BA05DA6E9 for ; Mon, 17 Oct 2005 01:41:26 -0300 (ADT) Received: from mta1.fe.internet.bosch.com (unknown [10.4.98.30]) by imta7.fe.bosch.de (Postfix) with ESMTP id 54FA73C017 for ; Mon, 17 Oct 2005 06:41:25 +0200 (CEST) Received: from mailgate.cl.internet.bosch.com (virusscan4.fe.internet.bosch.com [10.4.98.10]) by mta1.fe.internet.bosch.com (Postfix) with ESMTP id 623988C019 for ; Mon, 17 Oct 2005 06:41:24 +0200 (CEST) Received: from cl-mail01.au.bosch.com (unknown [10.23.5.53]) by mailgate.cl.internet.bosch.com (Postfix) with ESMTP id 261C65282A for ; Mon, 17 Oct 2005 14:41:22 +1000 (EST) X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: Question about functions Date: Mon, 17 Oct 2005 14:41:21 +1000 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [SQL] Question about functions Thread-Index: AcXSyuKhnk+MXjhRRx6dCqzn74mmPAACfklA From: "Stewart Ben (RBAU/EQS4) *" To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.57 required=5 tests=[AWL=-0.011, DNS_FROM_RFC_ABUSE=0.374, UPPERCASE_25_50=0.207] X-Spam-Level: X-Archive-Number: 200510/177 X-Sequence-Number: 23030 Mike, > I am trying to run this function but the return is not=20 > correct. If I run the select statement from the psql command=20 > line it works. My guess is that the WHERE clause could be=20 > causing the problem. Then again, it may be how I am using=20 > the FOR loop. The ides column is of type TEXT. >=20 > CREATE OR REPLACE FUNCTION sp_description_search(varchar)=20 > RETURNS varchar AS $$ -- <=3D=3D Problem is here > DECLARE > myrec record; > BEGIN > FOR myrec IN SELECT * FROM tblStuff WHERE ides LIKE '%$1%' LOOP > RETURN NEXT myrec; -- <=3D=3D 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/=20