pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ana Roizen <aroizen@sinectis.com.ar>
To: pgsql-sql@hub.org <pgsql-sql@hub.org>
Subject: Updating and null values.
Date: Tue, 18 May 1999 11:44:57 -0300
Message-ID: <37417CE9.B967D174@sinectis.com.ar> (raw)

Hi!
Can anyone help me with this?

Say I have two tables :
tt(tx1 int4, tx2 oid,ty1 int4, ty2 oid );
xx(x1 int4, x2 oid)
yy (y1 int4, y2 oid)
I want to perform the following query:

UPDATE tt  SET tx1 =  A.x1,  ty1=B.y1  FROM xx A, yy B WHERE tx2 =  A.x2
AND ty2 = B.y2;

This works fine while there's always a matching tuple of xx and yy for
tx2 and ty2.  If one of the values doesn't find a matching tuple, then
the whole tt tuple isn't updated.

Example:
Suppose the following instances of my tables:


tt = (     (     ,  500,     ,100),
            (     ,  600,     ,200 ),
            (     ,  0,         ,300 ) )
xx= (    (2, 500),    (3, 600),    ( 4, 1000))
yy =(    (2,100),    (1,200) ,    (4, 300) )


The result of the query would then be:
tt = (     (    2 ,  500,   2  ,100),
            (    3 ,  600,   1   ,200 ),
            (     ,  0,         ,300 ) )
It only updated the first two tuples.
I wanted the third tuple to be updated too. It should have the new
values (     ,0    ,4,  300), as y1 is not null, so ty1 should now have
the same value as y1.(not a null one)

Does anyone have an idea on how to solve this?
Any help would be great.
Thanks.

    Ana Roizen.




view thread (2+ messages)  latest in thread

Message-ID: <37417CE9.B967D174@sinectis.com.ar>
Permalink:  ../37417CE9.B967D174@sinectis.com.ar/
Also on:    postgresql.org/message-id/37417CE9.B967D174@sinectis.com.ar

 · 

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 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: aroizen@sinectis.com.ar, pgsql-sql@hub.org
  Subject: Re: Updating and null values.
  In-Reply-To: <37417CE9.B967D174@sinectis.com.ar>
  References: <37417CE9.B967D174@sinectis.com.ar>

* 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