From: Nuchanard Chiannilkulchai <nuch@valigene.com>
To: pgsql-sql@postgreSQL.org
Subject: null values to be replaced by a default value
Date: Tue, 20 Apr 1999 17:31:41 +0200
Message-ID: <371C9DDD.AC4ED97B@valigene.com> (raw)
Hi,
To return one value not null, i've created a function :
CREATE FUNCTION isnull (int4,int4 ) RETURNS int4 AS '
BEGIN
IF ($1 IS NULL) THEN
RETURN $2;
ELSE
RETURN $1;
END IF;
END;
' LANGUAGE 'plpgsql';
select isnull(my_int,0) as number, sample_id from my_table;
but I got
number |sample_id
------+---------
| 13
| 15
What should I do to have '0' in the column 'number' instead of NULL ?
Thanks,
nuch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: nuch@valigene.com
Subject: Re: null values to be replaced by a default value
In-Reply-To: <371C9DDD.AC4ED97B@valigene.com>
References: <371C9DDD.AC4ED97B@valigene.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox