> hope that it will help you better
I am afraid that it will not help, as you did not reveal the rules for obtaining the new codes.
Why are they 15, 21, 33, 101?
Why not 16, 26, 42, 315?
Why not 17, 31, 56, 538?
Why not ...?
they are simple inserts for each row
the problem is that there can be more than 1 command running this copy, so it could happens that the ID's are nor sequential for one command if there is another one doing the same procedure.
Maybe I didn't made myself clear.
the ID's are sequential, but if someone is inserting rows in that table at the same time that I'm running the copy, the new tree structure will not have a sequential ID, because it could be interrupted by the other insert.
In Oracle when your query runs it "sees" the tables as they were at the start of the select. Unlike other databases if someone else is inserting at the same time as you do your select you WONT see their data.
So I think the insert statement I used earlier will work, you just have to make sure the amount you shift by is big enough that any body inserting at the same wont clash with your new IDs. In most Oracle apps these IDs would be generated by a sequence and after your insert you would increment the sequence to a value greater than the max ID value you just inserted.
The more complicated alternative to avoiud messing with the sequence would be to create a temp table as a copy of the data. Then add a NEW_ID column and populate that with your sequence. Then write an insert statement to copy the data from the temp table to the original using the NEW_ID instead.