Received: from carabosse.oleane.net (carabosse.oleane.net [194.2.28.5]) by hub.org (8.9.3/8.9.1) with ESMTP id MAA49213 for ; Tue, 20 Apr 1999 12:25:42 -0400 (EDT) (envelope-from nuch@valigene.com) Received: from tom.oleane.net (smtp.dial.oleane.com [194.2.0.54]) by carabosse.oleane.net with ESMTP id SAA04379 for ; Tue, 20 Apr 1999 18:25:40 +0200 Received: from valigene.com ([62.161.254.162]) by tom.oleane.net (8.8.8/8.8.8) with ESMTP id SAA16481 for ; Tue, 20 Apr 1999 18:25:32 +0200 Sender: nuch@tom.oleane.net Message-ID: <371C9DDD.AC4ED97B@valigene.com> Date: Tue, 20 Apr 1999 17:31:41 +0200 From: Nuchanard Chiannilkulchai Organization: ValiGene X-Mailer: Mozilla 4.07 [en] (X11; I; Linux 2.0.36 i686) MIME-Version: 1.0 To: pgsql-sql@postgreSQL.org Subject: null values to be replaced by a default value Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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