default value returned from sql stmt - Mailing list pgsql-general

From David Salisbury
Subject default value returned from sql stmt
Date
Msg-id 4F74DF37.3070504@globe.gov
Whole thread Raw
Responses Re: default value returned from sql stmt  (Chris Angelico <rosuav@gmail.com>)
Re: default value returned from sql stmt  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-general
In trying to get an sql stmt to return a default value, I read in the docs..

"The COALESCE function returns the first of its arguments that is not null. Null is returned only if all arguments are
null.It is  
often used to substitute a default value for null values when data is retrieved for display, for example:
SELECT COALESCE(description, short_description, '(none)') ..."

But I seem to be missing something:

development=# create table t1 ( anum integer );
CREATE TABLE

development=# insert into t1 values ( 2 ), (3);
INSERT 0 2

development=# select * from t1;

  anum
------
     2
     3

development=# select  coalesce(anum,100) from t1 where anum = 4;
  coalesce
----------
(0 rows)

Do I have to resort to PLPGSQL for this?

thanks for any info,

-ds

oh.. running 9.1

pgsql-general by date:

Previous
From: John R Pierce
Date:
Subject: Re: Managing two sets of data in one database
Next
From: Chris Angelico
Date:
Subject: Re: default value returned from sql stmt