Re: Question about functions - Mailing list pgsql-sql

From Richard Huxton
Subject Re: Question about functions
Date
Msg-id 43535E2D.8080500@archonet.com
Whole thread Raw
In response to Question about functions  (Mike Plemmons <mikeplemmons@gmail.com>)
List pgsql-sql
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


pgsql-sql by date:

Previous
From: Richard Huxton
Date:
Subject: Re: Question about functions
Next
From: Richard Huxton
Date:
Subject: Re: Question about functions