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 DFAE6D9EF7 for ; Mon, 17 Oct 2005 05:20:32 -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 91724-06 for ; Mon, 17 Oct 2005 08:20:30 +0000 (GMT) Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by svr1.postgresql.org (Postfix) with ESMTP id 49FABD7AD6 for ; Mon, 17 Oct 2005 05:20:30 -0300 (ADT) Received: from mainbox.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id F38BC41513C; Mon, 17 Oct 2005 09:20:26 +0100 (BST) Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id D371515ED9; Mon, 17 Oct 2005 09:17:52 +0100 (BST) Received: from mainbox.archonet.com ([127.0.0.1]) by localhost (mainbox [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 12591-01; Mon, 17 Oct 2005 09:17:50 +0100 (BST) Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 35BBF15ED5; Mon, 17 Oct 2005 09:17:50 +0100 (BST) Message-ID: <43535E2D.8080500@archonet.com> Date: Mon, 17 Oct 2005 09:17:49 +0100 From: Richard Huxton User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051010) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Mike Plemmons Cc: PostgreSQL List Subject: Re: Question about functions References: <2f8663320510162024j17b4fdb0n4d2b5df1e32d1863@mail.gmail.com> In-Reply-To: <2f8663320510162024j17b4fdb0n4d2b5df1e32d1863@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.059 required=5 tests=[AWL=0.009, FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200510/179 X-Sequence-Number: 23032 Mike Plemmons wrote: > 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. > FOR myrec IN SELECT * FROM tblStuff WHERE ides LIKE '%$1%' LOOP You're assuming plpgsql does variable interpolation in a similar way to Perl/shell etc. It doesn't. You'll want something like: ...LIKE '%' || $1 || '%' -- Richard Huxton Archonet Ltd