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