X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 10A1A8B9F0C for ; Mon, 31 Jan 2005 22:27:30 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 66311-01 for ; Mon, 31 Jan 2005 22:27:24 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.199]) by svr1.postgresql.org (Postfix) with ESMTP id C8D9B8B9F08 for ; Mon, 31 Jan 2005 22:27:24 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 67so668327wri for ; Mon, 31 Jan 2005 14:27:25 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=kSVJsf8ryqIUFmUINgAR8rZfQRmaqBd72sDRWb9o+FjcqdSU4iIicn1j1XigLBTBl/ZkForkCLnYqf0f5UBKOhSHmE1N0KpONTL3sGwZHy030SqPnDtKWC+e2F+n/CIR5aqxPZPEjsAgmNroADRNrUZ9KNtDpOvYwpgx8gN44dk= Received: by 10.54.54.80 with SMTP id c80mr362902wra; Mon, 31 Jan 2005 14:27:25 -0800 (PST) Received: by 10.54.4.71 with HTTP; Mon, 31 Jan 2005 14:27:25 -0800 (PST) Message-ID: <6c21003b05013114272504d72e@mail.gmail.com> Date: Mon, 31 Jan 2005 16:27:25 -0600 From: Don Drake Reply-To: Don Drake To: Stephan Szabo Subject: Re: plpgsql functions and NULLs Cc: pgsql-sql@postgresql.org In-Reply-To: <20050131132701.G12960@megazone.bigpanda.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <6c21003b0501301141234c256b@mail.gmail.com> <20050131132701.G12960@megazone.bigpanda.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.024 tagged_above=0 required=5 tests=RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200501/320 X-Sequence-Number: 20108 You learn something new everyday. I've never seen that syntax before, and it works like a charm!! Thanks a ton. -Don On Mon, 31 Jan 2005 13:31:34 -0800 (PST), Stephan Szabo wrote: > > On Sun, 30 Jan 2005, Don Drake wrote: > > > OK, I have a function that finds records that changed in a set of > > tables and attempts to insert them into a data warehouse. > > > > There's a large outer loop of candidate rows and I inspect them to see > > if the values really changed before inserting. > > > > My problem is that when I look to see if the row exists in the > > warehouse already, based on some IDs, it fails when an ID is NULL. > > The ID is nullable, so that's not a problem. > > > > But I'm forced to write an IF statement looking for the potential NULL > > and write 2 queries: > > > > IF omcr_id is null > > select * from .... > > WHERE omcr_id is NULL > > AND ... > > ELSE > > select * from .... > > WHERE omcr_id=candidate.omcr_id > > AND .... > > END IF; > > Hmm, perhaps some form like: > > WHERE not(candidate.omcr_id is distinct from omcr_id) > > -- Donald Drake President Drake Consulting http://www.drakeconsult.com/ 312-560-1574