Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Retain the 1st record ; delete the rest

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
wastedmaky

New User


Joined: 06 Oct 2006
Posts: 5
Location: manila, philippines

PostPosted: Thu Aug 30, 2007 9:13 am    Post subject: Retain the 1st record ; delete the rest
Reply with quote

I have a query which selects 4 equal records, i want to keep the 1st record and delete the rest. Can anyone help me on how the query should go?
Thanks for your help..
-=wastedmaky=-
Back to top
View user's profile Send private message

dick scherrer

Site Director


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

PostPosted: Thu Aug 30, 2007 9:10 pm    Post subject:
Reply with quote

Hello,

It would help if you clarify "4 equal records". What if more or less than 4 meet the selection criteria?

You could declare a cursor, fetch the rows that meet the selection criteria, and delete the rows fetched after the first one.

If you post some example rows, it may help us understand your requirement. You example should include rows that would be selected and rows that would not.
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Sun Sep 16, 2007 12:11 pm    Post subject: Reply to: Retain the 1st record ; delete the rest
Reply with quote

Quote:
I have a query which selects 4 equal records

Is your query designed to select only 4 records, neither less nor more.

Quote:
i want to keep the 1st record and delete the rest.

Delete from where, from the query results or from the table icon_rolleyes.gif
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Sun Sep 16, 2007 7:12 pm    Post subject:
Reply with quote

If the rows are identical all the way through, a DELETE FROM Table WHERE is going to delete all 4 rows. He needs to save one off in memory, delete all of them and then put one back in.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Mon Sep 17, 2007 8:45 am    Post subject:
Reply with quote

Can this help-

http://www.ibmmainframes.com/viewtopic.php?t=24159
Let us know if your requirement is different.
Back to top
View user's profile Send private message
md nisar

New User


Joined: 14 Sep 2007
Posts: 2
Location: pune

PostPosted: Tue Sep 18, 2007 11:06 am    Post subject:
Reply with quote

please check the ROWID of that 4 records ...then delete records based on the rowid.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Copy 4 byte of data from the last rec... arunsoods DFSORT/ICETOOL 9 Fri Oct 06, 2017 12:15 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts Skip file from delete pema_yozer All Other Mainframe Topics 3 Tue Aug 29, 2017 3:19 pm
No new posts Repeat part of record multiple times Learncoholic DFSORT/ICETOOL 4 Tue Aug 29, 2017 11:33 am
No new posts Delete IMS remote transaction when MO... Sam Singh IMS DB/DC 0 Wed Aug 23, 2017 9:12 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us