Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

query to rearrange the order

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

Active User


Joined: 31 Aug 2006
Posts: 216
Location: India

PostPosted: Wed Sep 24, 2008 12:08 pm    Post subject: query to rearrange the order
Reply with quote

I have a table called EMP which contains No and Name.

No
1
2
3
4
5
6
7
8

If i delete the 4th records other are rearranged such that result is

1
2
3
4
5
6
7

Can anyone throw some suggestion on this.
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10211
Location: italy

PostPosted: Wed Sep 24, 2008 12:21 pm    Post subject: Reply to: query to rearrange the order
Reply with quote

the question might be clear to You, but for us is confusing...
there is no fourth record in a db2 table

but
/mind reading on
maybe what you meant is that
You want to delete the row with a key of 4
shift all the other records up/down one position
/mind reading off

in any other case You showed only that the row wit a key of 8 has been deleted
Back to top
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 216
Location: India

PostPosted: Wed Sep 24, 2008 12:29 pm    Post subject: Re: Reply to: query to rearrange the order
Reply with quote

enrico-sorichetti wrote:
the question might be clear to You, but for us is confusing...
there is no fourth record in a db2 table

but
/mind reading on
maybe what you meant is that
You want to delete the row with a key of 4
shift all the other records up/down one position
/mind reading off

in any other case You showed only that the row wit a key of 8 has been deleted


Good Mind Reading Enrico icon_biggrin.gif . You are Correct.

Yes. If the forth record is deleted then the other records should be down by one.
Back to top
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 216
Location: India

PostPosted: Wed Sep 24, 2008 1:04 pm    Post subject: Reply to: query to rearrange the order
Reply with quote

Any suggestions form DB2 Experts Pls.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Sep 24, 2008 2:03 pm    Post subject:
Reply with quote

Sri,

I could guess at what you want but, you need to supply a few more details.
But then I am not a db2 expert, so maybe that is where the problem lays.
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: Wed Sep 24, 2008 8:39 pm    Post subject:
Reply with quote

Hello,

Quote:
If the forth record is deleted then the other records should be down by one.
Why do you believe this should happen? Is this not the primary key for the data? What about other informatoin in the system that relates to the "No"?

A "No" might be deleted, but i believe there are potential problems if the key values greater the deleted key are "moved up".

There may also be issues with multiple users . . .
Back to top
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 216
Location: India

PostPosted: Thu Sep 25, 2008 11:57 am    Post subject: Reply to: query to rearrange the order
Reply with quote

It is a scenario given to me to get the ways of doing it.I am sure of its future usage.Thanks to every one.
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 Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts Order BY AND Index Nileshkul DB2 2 Sat Dec 31, 2016 6:33 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us