On Mon, Jul 6, 2009 at 6:37 AM, Mohan Raj B<brightmohan(at)gmail(dot)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