Re: Pgsql dynamic statements and null values

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Guy Rouillier <guyr(at)masergy(dot)com>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Pgsql dynamic statements and null values
Date: 2005-03-09 10:50:46
Message-ID: 20050309105046.GD1239@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Mar 08, 2005 at 04:30:54PM -0600, Guy Rouillier wrote:
> This is such a common usage pattern that I'm pretty sure I'm missing
> something basic. Pgsql provides quote_literal to aid with inserting a
> literal string into a dynamically prepared statement. My opinion is
> that quote_literal should handle nulls as well, but if quote_literal
> can't be changed for historical reasons, then providing another function
> like check_null below would be very useful. Basically, such a function
> should supply the value NULL if the incoming value is null, or the
> incoming value otherwise.

Lookup the COALESCE and NULLIF functions.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Gordan Bobic 2005-03-09 11:13:21 Triggers and User Defined Trigger Functions
Previous Message Alban Hertroys 2005-03-09 09:39:26 Re: Disabling triggers in a transaction