Re: COALESCE not filtering well. - Mailing list pgsql-general

From Greg Stark
Subject Re: COALESCE not filtering well.
Date
Msg-id 407d949e0907060554v88667c1h4fa803a1041aed71@mail.gmail.com
Whole thread Raw
In response to COALESCE not filtering well.  (Mohan Raj B <brightmohan@gmail.com>)
List pgsql-general
On Mon, Jul 6, 2009 at 6:37 AM, Mohan Raj B<brightmohan@gmail.com> 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

pgsql-general by date:

Previous
From: Sebastien FLAESCH
Date:
Subject: Re: Normalize INTERVAL ouput format in a db driver
Next
From: Tom Lane
Date:
Subject: Re: Postgres 8.3.7 Server Crash: failed to add item to the right sibling in index