I have two tables A and B.
A looks like this:
ID | Name | Designation
B looks like this:
ID | Department
When adding rows in A, the ID is generated automatically using a sequence. After rows are added in A rows must be added to B, with the same A’s newly generated IDs in B’s ID field and the Department value must be duplicated from the row above. Lets say 5 rows are added in A, then the same number of rows which is 5 must be added in B with A’s newly generated 5 IDs and with the Department column value duplicated for all the 5 rows with an already existing row above.
What is the SQL query for the same?
Note: I know that for this example, these two tables should have been combined to one but these here are sample tables used to portray the same blocker at work. So I can’t redesign the tables.