default value for select? - Mailing list pgsql-sql

From Mark Fenbers
Subject default value for select?
Date
Msg-id 427F9685.8050104@noaa.gov
Whole thread Raw
Responses Re: default value for select?  ("Keith Worthington" <keithw@narrowpathinc.com>)
Re: default value for select?  (Tony Wasson <ajwasson@gmail.com>)
Re: default value for select?  (Philip Hallstrom <postgresql@philip.pjkh.com>)
List pgsql-sql
I want to update a column in myTable.  The value this column is set to depends on a nested select statement which
sometimesreturns 0 rows instead of 1.  This is a problem since the column I'm trying to update is set to refuse nulls. 
Here'sa sample:<br /><br /> update myTable set myColumn = (Select altColumn from altTable where altColumn != 'XXX'
limit1) where myColumn = 'XXX';<br /><br /> MyColumn cannot accept nulls, but sometimes "Select altColumn ..." returns
0rows, and thus, the query fails.  <br /><br /> Is there a way to set a default value to be inserted into myColumn if
andwhen "select altColumn ..." returns zero rows?<br /><br /> Mark<br /> 

pgsql-sql by date:

Previous
From: "ALÝ ÇELÝK"
Date:
Subject: Re: diff value retuns, debug mode and play mode
Next
From: "Keith Worthington"
Date:
Subject: Re: default value for select?