pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rajesh Kumar Mallah <mallah@trade-india.com>
To: pgsql-sql@postgresql.org
Subject: question about visibilty while updating multiple rows .
Date: Wed, 9 Apr 2003 12:47:59 +0530
Message-ID: <200304091247.59378.mallah@trade-india.com> (raw)



Hi,

If an update statement is affecting multiple rows of a table X ,
Does a subselect (selecting from X only)  inside EXISTS part of outer query 
able to see the changes when rows are being updated one by one by outer query?


for example consider following set of data rows:

+------------+-----------------------+------+----------+----------------------------------+
| profile_id |        co_name        | size | deletion |               md5                |
+------------+-----------------------+------+----------+----------------------------------+
|     212161 | ATITH FIBRE PVT. LTD. | FL   | t        | edc462794427724b7d132e3b1387d69f |
|     212159 | ATITH FIBRE PVT. LTD. | 1HS  | f        | edc462794427724b7d132e3b1387d69f |
|     216225 | ATITH FIBRE PVT. LTD. | 1HS  | f        | edc462794427724b7d132e3b1387d69f |
|     216226 | ATITH FIBRE PVT. LTD. | 1HS  | f        | edc462794427724b7d132e3b1387d69f |
+------------+-----------------------+------+----------+----------------------------------+

begin work;

UPDATE eyp_profiles_table SET

        deletion=true 

	WHERE 

	co_name='ATITH FIBRE PVT. LTD.' AND 
        deletion is false and 
	
	EXISTS (select * from eyp_profiles_table a where a.md5=eyp_profiles_table.md5 and 
		 a.deletion is false and a.profile_id <> eyp_profiles_table.profile_id) ;


my original problem is to update in such a way that i get below finally (observer the deletion column)
+------------+-----------------------+------+----------+----------------------------------+
| profile_id |        co_name        | size | deletion |               md5                |
+------------+-----------------------+------+----------+----------------------------------+
|     212161 | ATITH FIBRE PVT. LTD. | FL   | t        | edc462794427724b7d132e3b1387d69f |
|     212159 | ATITH FIBRE PVT. LTD. | 1HS  | t        | edc462794427724b7d132e3b1387d69f |
|     216225 | ATITH FIBRE PVT. LTD. | 1HS  | t        | edc462794427724b7d132e3b1387d69f |
|     216226 | ATITH FIBRE PVT. LTD. | 1HS  | f        | edc462794427724b7d132e3b1387d69f |
+------------+-----------------------+------+----------+----------------------------------+
so that only one entry per md5 record exists.



Regds
mallah.






-- 
Rajesh Kumar Mallah,
Project Manager (Development)
Infocom Network Limited, New Delhi
phone: +91(11)6152172 (221) (L) ,9811255597 (M)

Visit http://www.trade-india.com ,
India's Leading B2B eMarketplace.




view thread (3+ messages)  latest in thread

Message-ID: <200304091247.59378.mallah@trade-india.com>
Permalink:  ../200304091247.59378.mallah@trade-india.com/
Also on:    postgresql.org/message-id/200304091247.59378.mallah@trade-india.com

 · 

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: mallah@trade-india.com
  Subject: Re: question about visibilty while updating multiple rows .
  In-Reply-To: <200304091247.59378.mallah@trade-india.com>

* 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