dbTalk Databases Forums  

SQL way to do this ?

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss SQL way to do this ? in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Aleanna10 (AT) gmail (DOT) com
 
Posts: n/a

Default SQL way to do this ? - 05-02-2006 , 02:27 PM






Not sure best way to explain this but I'll try. I have a table with
some of list ids,
I need to merge them together under one list id. We separate our
list_id in blocks of 20000


So lets say the dest list_id = 2000 and source list_id = 3000

I need to update all source list_id from 3000 to 2000 but only 20000 at
a time.

if source list id 3000 has 56,000, the first 20,000 will have b_id of 1
and next
20,000 will have b_id of 2, and the next 16,000 will have b_id of 3.
I also have to take in account that the desti list_id doesnt
overflow with more then 20k per b_id.

so given the following data

count(*) b_id dest list_id
20,000 1 2000
20,000 2 2000
7,000 3 2000


count(*) b_id source list_id
20,000 1 3000
20,000 2 3000
16,000 3 3000


after the update the final data should be

count(*) b_id dest list_id
20,000 1 2000
20,000 2 2000
20,000 3 2000
20,000 4 2000
20,000 5 2000
3,000 6 2000


Is there any better way to do this in oracle. I can do it
programmatically fine but it seems very
hackish too me. Any help is greatly appreaciated.

note (there could be 1 or more source lists)

Thanks.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.