IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Can we update duplicate rows in a spufi by keeping any row


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
maheshvamsi

New User


Joined: 22 Mar 2008
Posts: 39
Location: bangalore

PostPosted: Wed Jul 06, 2011 10:51 pm
Reply with quote

Hi,

by using spufi can we update a column duplicate rows by keeping one row unchanged.

Table:

Code:
col1 col2 col3
a      b     1
a      b     1
c      d     2
c      d     2


Based in col1 & col2 update col3

Output:

Code:
col1 col2 col3
a      b     1
a      b     0
c      d     2
c      d     0
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Jul 06, 2011 11:02 pm
Reply with quote

Hello,

How/why is this a spufi question?

If you can define the "rules" you should be able to write the needed sql. . .

What has been posted is too limited a sample to establish "rules" (at least for me).
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Thu Jul 07, 2011 3:21 pm
Reply with quote

db2 V9:
Code:
update table1 B set col3 = 0
where rid(B) not in (select min(rid(A)) from table1 A group by col1,col2,col3)
Back to top
View user's profile Send private message
maheshvamsi

New User


Joined: 22 Mar 2008
Posts: 39
Location: bangalore

PostPosted: Thu Jul 07, 2011 5:42 pm
Reply with quote

Hi Dick,

Its not a question about spufi, I want to know whether we can update the table using one querry instead of writing a program.

Thank you GuyC, for providing the solution.

icon_smile.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts DELETE SPUFI DB2 1
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Duplicate transid's declared using CEDA CICS 3
No new posts Adding QMF and SPUFI to the ISPF menu DB2 20
No new posts Exclude rows with > than x occurre... DFSORT/ICETOOL 6
Search our Forums:

Back to Top