I have following table structure
ID Name Parent_ID
1 abc 0
2 efg 1
3 hij 1
4 klm 2
5 nop 3
and so on….id is generated in a sequence
I want a PL/SQL to coy this same data in same table but id should be generated by seq and Parent_ID should be mapped accordingly…that means..after PL/SQL it should look like
ID Name Parent_ID
1 abc 0
2 efg 1
3 hij 1
4 klm 2
5 nop 3
6 abc 0
7 efg 6
8 hij 6
9 klm 7
10 nop 8
can any1 help me in this…thnx
So, here is your original data:
This procedure populates a PL/SQL collection with the extant rows. It loops through those rows, populating an associative array with a new ID which is indexed by the original ID. (Note the assignment uses the 11g syntax for getting a sequence value, rather than the traditional selecting from DUAL). The ID is then chnaged to the new value, and the PARENT_ID is updated with the value stored in the associative array. Lastly the new rows are inserted into the table using the bulk
FORALLsyntax,And, lo!