pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mark Fenbers <Mark.Fenbers@noaa.gov>
To: pgsql-sql@postgresql.org
Subject: default value for select?
Date: Mon, 09 May 2005 12:57:41 -0400
Message-ID: <427F9685.8050104@noaa.gov> (raw)

This is a multi-part message in MIME format.
--------------090904020309000109020002
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#333399">
I want to update a column in myTable.&nbsp; The value this column is set to
depends on a nested select statement which sometimes returns 0 rows
instead of 1.&nbsp; This is a problem since the column I'm trying to update
is set to refuse nulls.&nbsp; Here's a sample:<br>
<br>
update myTable set myColumn = (Select altColumn from altTable where
altColumn != 'XXX' limit 1) where myColumn = 'XXX';<br>
<br>
MyColumn cannot accept nulls, but sometimes "Select altColumn ..."
returns 0 rows, and thus, the query fails.&nbsp; <br>
<br>
Is there a way to set a default value to be inserted into myColumn if
and when "select altColumn ..." returns zero rows?<br>
<br>
Mark<br>
</body>
</html>

--------------090904020309000109020002
Content-Type: text/x-vcard; charset=utf-8;
 name="Mark.Fenbers.vcf"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="Mark.Fenbers.vcf"

begin:vcard
fn:Mark Fenbers
n:Fenbers;Mark
org:DoC/NOAA/NWS/OHRFC
adr:;;1901 South SR 134;Wilmington;OH;45177-9708;USA
email;internet:Mark.Fenbers@noaa.gov
title:Sr. HAS Meteorologist
tel;work:937-383-0430 x246
x-mozilla-html:TRUE
url:http://weather.gov/ohrfc
version:2.1
end:vcard


--------------090904020309000109020002--



Attachments:

Mark.Fenbers.vcf (text/x-vcard, 281B) download begin:vcard fn:Mark Fenbers n:Fenbers;Mark org:DoC/NOAA/NWS/OHRFC adr:;;1901 South SR 134;Wilmington;OH;45177-9708;USA email;internet:Mark.Fenbers@noaa.gov title:Sr. HAS Meteorologist tel;work:937-383-0430 x246 x-mozilla-html:TRUE url:http://weather.gov/ohrfc version:2.1 end:vcard

view thread (4+ messages)  latest in thread

Message-ID: <427F9685.8050104@noaa.gov>
Permalink:  ../427F9685.8050104@noaa.gov/
Also on:    postgresql.org/message-id/427F9685.8050104@noaa.gov

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: Mark.Fenbers@noaa.gov
  Subject: Re: default value for select?
  In-Reply-To: <427F9685.8050104@noaa.gov>

* 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