Team, I have source table
SRC_TBL
--------------
STATUS EMP_ID
--------------
VALID E1
VALID E2
VALID E3
VALID E4
VALID E5
VALID E6
INVALID E7
INVALID E8
VALID E9
VALID E10
VALID E11
VALID E12
VALID E13
VALID E14
- Need to pick from SRC_TBL with
STATUS ='VALID'and feed tableTAR_TBL - Divide the total VALID records into batches with
BATCH_IDwith 5 recs/batch - This divide value
5will be passed as parameter. Real case can be100 or 200per batch. - Sample data is just few here. Real case 10000+records in
SRC_TBLtable - Hence need to handle in BULK COLLECT
- But use of IF/WHEN is not allowed in BULK COLLECT's forallin loop
TAR_TBL
STATUS EMP_ID BATCH_ID
VALID E1 1
VALID E2 1
VALID E3 1
VALID E4 1
VALID E5 1
VALID E6 2
VALID E9 2
VALID E10 2
VALID E11 2
VALID E12 2
VALID E13 3
VALID E14 3
Here's the code for your question.