I am trying to transfer data from one table to another. But in the process I need to do something extra I am just wondering is it possible to do something like this in SQL or PL/SQL alone.
source target
------------------- ------------------------
| id | name | qty | | id | source_id | qty |
------------------- ------------------------
| 1 | test | 2 | | 1 | 1 | 1 |
------------------- ------------------------
| 2 | ago | 1 | | 2 | 1 | 1 |
------------------- ------------------------
| 3 | 2 | 1 |
-----------------------
Here based on the quantity in source table I will have to insert multiple records. Quantity could be of any number. ID in target table is auto incremented. I tried this
INSERT INTO target (SELECT id, qty FROM source);
But this does not take care of the qty loop.
target?