From: Richard Huxton <dev@archonet.com>
To: Mike Plemmons <mikeplemmons@gmail.com>
Cc: PostgreSQL List <pgsql-sql@postgresql.org>
Subject: Re: Question about functions
Date: Mon, 17 Oct 2005 09:17:49 +0100
Message-ID: <43535E2D.8080500@archonet.com> (raw)
In-Reply-To: <2f8663320510162024j17b4fdb0n4d2b5df1e32d1863@mail.gmail.com>
References: <2f8663320510162024j17b4fdb0n4d2b5df1e32d1863@mail.gmail.com>
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
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: dev@archonet.com, mikeplemmons@gmail.com
Subject: Re: Question about functions
In-Reply-To: <43535E2D.8080500@archonet.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