Re: plpgsql allowing null fields in insert commands? - Mailing list pgsql-novice

From Stephan Szabo
Subject Re: plpgsql allowing null fields in insert commands?
Date
Msg-id 20050316060521.E47369@megazone.bigpanda.com
Whole thread Raw
In response to plpgsql allowing null fields in insert commands?  ("Celia McInnis" <celia@drmath.ca>)
Responses Re: plpgsql allowing null fields in insert commands?
List pgsql-novice
On Tue, 15 Mar 2005, Celia McInnis wrote:

> In a plpgsql procedure is there any way to form an insert command which has
> some null values for values of the inputs?
>
> Currently when I form such a command, the command becomes null if there are
> any null values inserted for the fields.

Are you making a query string for execute?
Something like:
 querystring := 'insert into foo(col1) values (' || variable || ')';
won't work if variable is null. You'd probably need something like:
 querystring := 'insert into foo(col1) values (' ||
  COALESCE(variable,'NULL') || ')';


pgsql-novice by date:

Previous
From: John DeSoi
Date:
Subject: Re: plpgsql allowing null fields in insert commands?
Next
From: Greg Lindstrom
Date:
Subject: XML and Postgres