Skip site navigation (1) Skip section navigation (2)

Re: Question about inserts

From: "Stijn Vanroye" <s(dot)vanroye(at)farcourier(dot)com>
To: "mike" <mike(at)redtux1(dot)uklinux(dot)net>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Question about inserts
Date: 2004-04-23 11:07:43
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
Maybe you can do something with this function:

[quote from the postgres docs]
9.12.2. COALESCE
COALESCE(value [, ...])
The COALESCE function returns the first of its arguments that is not null. Null is returned only if all arguments are null. This is often useful to substitute a default value for null values when data is retrieved for display, for example: 

SELECT COALESCE(description, short_description, '(none)') ...

Like a CASE expression, COALESCE will not evaluate arguments that are not needed to determine the result; that is, arguments to the right of the first non-null argument are not evaluated. 
[end quote]

Isn't it possible to pass "NULL" to the query in stead of ''?
eg. update table set datefield=NULL 


Stijn Vanroye

> Is it possible to to the following
> I have tables which are updated via webpage (perl) with fields of type
> int and date (all nullable). If the values are blank the entire insert
> fails, with a wrong type error. 
> Is there any way to stop this behaviour so that the valid 
> information is
> allowed,but the blank values get ignored. 
> ---------------------------(end of 
> broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?


pgsql-general by date

Next:From: Paul ThomasDate: 2004-04-23 12:44:10
Subject: Re: Question about inserts
Previous:From: mikeDate: 2004-04-23 10:36:51
Subject: Question about inserts

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group