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

query to rearrange the order


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

Active User


Joined: 31 Aug 2006
Posts: 218
Location: India

PostPosted: Wed Sep 24, 2008 12:08 pm
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

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Wed Sep 24, 2008 12:21 pm
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: 218
Location: India

PostPosted: Wed Sep 24, 2008 12:29 pm
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: 218
Location: India

PostPosted: Wed Sep 24, 2008 1:04 pm
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
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

Moderator Emeritus


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

PostPosted: Wed Sep 24, 2008 8:39 pm
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: 218
Location: India

PostPosted: Thu Sep 25, 2008 11:57 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts RC query -Time column CA Products 3
No new posts Rotate partition-logical & physic... DB2 0
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
Search our Forums:

Back to Top