Page 1 of 1

Sort

Posted: Mon May 28, 2007 3:55 am
by cosec
Hello,

I am loading data in to DB2 Tables. The Source is a sorted sequential file and all my target tables are sorted except for one. Is there a way to correct this without using a sort stage ?

Thanks

Hazmar

Posted: Mon May 28, 2007 6:00 am
by rafik2k
If you don't want use sort stage, then treat the unsorted table as dummy table. Create another new table with the same structure.

Select all columns from dummy table as order by clause in asc or desc and pass as it is into target new table.

Posted: Mon May 28, 2007 7:48 am
by DSguru2B
Yea, do an "order by clause" on this unsorted table and load it to a flat file. Pass a truncate on the table and reload the sorted data.

Re: Sort

Posted: Mon May 28, 2007 7:51 am
by chulett
cosec wrote:and all my target tables are sorted except for one.
What is that supposed to mean? Is it a 'DB2 thing' where tables can be... 'sorted'? :?

Or are we just talking about doing an initial load sorted in a fashion that matches the PK of the target table?

Re: Sort

Posted: Mon May 28, 2007 9:00 am
by Minhajuddin
cosec wrote:Hello,

I am loading data in to DB2 Tables. The Source is a sorted sequential file and all my target tables are sorted except for one. Is there a way to correct this without using a sort stage ?

Thanks

Hazmar
What do you mean by "Is there a way to correct this without using a sort stage ?". Can you shed some light on it.

Posted: Mon May 28, 2007 12:54 pm
by michaeld
You can set the APT_NO_SORT_INSERTION parameter and in the sort stage set the "don't sort previousley sorted" option. You also need to make sure that the job runs in sequential mode. Otherwise partitioning may mess up the order.

If you need to run it in parallel mode then you will need to pick the sorted collection method in your DB stage. This will do some sorting, but it's not as bad as a total resort because it will only do a single pass on the data.