Split a result set into equal parts

I am trying to use multi-threading in my code for faster performance. I get a result set using a stored procedure as follows -
      OPEN p_eft_noc FOR
            SELECT
            NOTICE_OF_CHANGE_ID,
            BATCH_NUMBER,
            ITEM_SEQ_NUMBER,
            ACCOUNT_NUMBER,
            ASSOCIATION_ID,
            MEMBERSHIP_NUMBER,
            ASSOCIATION_ID,
            PROCESS_DATE
            from NOTICE_OF_CHANGE eftnoc
        where nvl(eftnoc.process_date, 'N') <> 'Y'
        order by MEMBERSHIP_NUMBER;
This result set can return any number of rows from 0 to 3000. I am using java code and once I obtain the result set, i need to divide it into 8 parts so that each part is processed separately in a thread.
Can someone help me, i need to figure out how to divide this result set...and should i do it in stored procedure itself or in java code and how. Thanks...
smahaj2Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
sdstuberConnect With a Mentor Commented:
easiest way would be to include a an extra column that designates your splits.

Does it matter how you thread it?

can the first row go to the first thread, 2nd row to second thread, up to 9th row to 1st thread again, and so on?

If so....

Then try something like this....
Each row will be identified by thread_id  0-7

OPEN p_eft_noc FOR
            SELECT
            MOD(ROWNUM,8)  thread_id
            NOTICE_OF_CHANGE_ID,
            BATCH_NUMBER,
            ITEM_SEQ_NUMBER,
            ACCOUNT_NUMBER,
            ASSOCIATION_ID,
            MEMBERSHIP_NUMBER,
            ASSOCIATION_ID,
            PROCESS_DATE
            from NOTICE_OF_CHANGE eftnoc
        where nvl(eftnoc.process_date, 'N') <> 'Y'
        order by MEMBERSHIP_NUMBER;



0
 
sdstuberCommented:
Do you need any further help?
0
All Courses

From novice to tech pro — start learning today.