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

How to physically sort & save records in a DB2 table ?


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

New User


Joined: 05 Dec 2006
Posts: 89
Location: chennai

PostPosted: Sat Jan 31, 2009 5:33 pm
Reply with quote

Hi,

I'm using CA-Platinum RC/update to insert new records(using repeat command and changing key values) and I could sucessfully commit my changes. Now, the inserted records are physically stored randomly and not in a sorted order.

I want the below EMP_ID columns to be sorted and saved in descending order i.e. Change the fetch order and save in descending order in table for selected records (note - I tried SORT EMP_ID D command but it is not getting saved in the sorted manner)


RUEDITC R11.5 ----- RC/Edit: Searched Column Mode ---- 09/01/31 05:34:54
COMMAND ===> SCROLL ===> CSR
For Table => Row number=> 1 OF 11947
Edit Mode => C Max Char => 070
SSID: DSNT ---------------------------------------------------------- USERID
OPT S EMP_ID PARTITION_NBR TEST_ID REC_ID
___ 190365 59373 0 0
___ 190375 59373 0 0
___ 190366 59373 0 0
___ 190368 59373 0 0
___ 190369 59373 0 0
___ 190376 59373 0 0
___ 190376 59373 0 0
___ 190376 59373 0 0
___ 190376 59373 0 0
___ 190376 59373 0 0
___ 190376 59373 0 0
___ 190376 59373 0 0
___ 190376 59373 0 0
___ 190376 59373 0 0
___ 190376 59373 0 0
___ 190376 59373 0 0
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Sat Jan 31, 2009 8:11 pm
Reply with quote

Hello,
Quote:
stored randomly and not in a sorted order.
You want to say that data in DB2 table should be in some sort-order, 'am not sure, how does it benefit?
Back to top
View user's profile Send private message
Bharath Bhat

Active User


Joined: 20 Mar 2008
Posts: 283
Location: chennai

PostPosted: Mon Feb 02, 2009 8:59 am
Reply with quote

Quote:
Now, the inserted records are physically stored randomly and not in a sorted order.


I don't think you have control over how the rows are stored in DB2.
We can retrieve the columns in sorted order but not save in sorted order. icon_rolleyes.gif
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: Mon Feb 02, 2009 9:19 am
Reply with quote

Hello,

Quote:
I don't think you have control over how the rows are stored in DB2.
Yup.

Even if you could store the rows in some order, why do so? Think of the problems this would cause for insert and update activities.

One of the rules of sql is that unless an ORDER BY is used in a SELECT, the sequence of retrieved rows will be unpredictable. If you need descending sequence for some process, specify this in the query.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Mon Feb 02, 2009 12:54 pm
Reply with quote

or may be your requirement is totally different & what you posted, you thnk, is a way to achieve it. If you post the actual requirement I believe some one will be around and there can be alternative solution..
Back to top
View user's profile Send private message
itjagadesh

New User


Joined: 05 Dec 2006
Posts: 89
Location: chennai

PostPosted: Mon Feb 02, 2009 9:18 pm
Reply with quote

Thank you all for your response!

I just wanted to test ORDER BY DESC clause(Records satisfying my test condition criteria are in ASC order in production, I tried loading from production but still it retains the same order,so I need to change the order for my testing).

Do we have control to physically position the records in a table using move,insert or other update actions thru RC/Update or file-aid for DB2?

Or by sorting the unloaded file and loading, will it load in the same sequence?

Jag.
Back to top
View user's profile Send private message
itjagadesh

New User


Joined: 05 Dec 2006
Posts: 89
Location: chennai

PostPosted: Mon Feb 02, 2009 9:33 pm
Reply with quote

Sorry a small correction, I wanted to test ORDER BY ASC not descending.
Back to top
View user's profile Send private message
Bharath Bhat

Active User


Joined: 20 Mar 2008
Posts: 283
Location: chennai

PostPosted: Mon Feb 02, 2009 10:26 pm
Reply with quote

Quote:
Records satisfying my test condition criteria are in ASC order in production, I tried loading from production but still it retains the same order,so I need to change the order for my testing


How can it retain the same order? As the folks have mentioned over and over again, There is NO defined order in which data is or can be stored in DB2 (relational database).

If you wanted to test order by clause, I'd suggest you go ahead without bothering about how the rows are stored. May be a better thing to bother about is the manner in which they are returned. icon_cool.gif
Back to top
View user's profile Send private message
itjagadesh

New User


Joined: 05 Dec 2006
Posts: 89
Location: chennai

PostPosted: Tue Feb 03, 2009 11:04 am
Reply with quote

Thanks
Bharath
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 How to save SYSLOG as text data via P... All Other Mainframe Topics 1
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 2
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top