Search Postgresql Archives

Re: COALESCE not filtering well.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jul 6, 2009 at 6:37 AM, Mohan Raj B<brightmohan@xxxxxxxxx> wrote:

> CREATE OR REPLACE FUNCTION sp_item(itemid integer, itemname character
> varying)


>   WHERE ( ( COALESCE($1,0)=0 OR  itemid=$1) AND (COALESCE($2, '')='' OR
> itemname LIKE '%'||$2||'%') ) LOOP

itemid and itemname are your parameters, they're being substituted in
the query so you're getting 10=10 and NULL LIKE '%'||NULL||'%'

-- 
greg
http://mit.edu/~gsstark/resume.pdf

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux