I have tables A and B with identity PKs ida and idb:
ex A:
ida col1 col2 idb
---------------------------
1 xxxx foo NULL
2 yyyy bar NULL
ex B:
idb col3 col4
----------------------
110 uuuu rrr
111 vvvv ttt
For each row in A I must insert a row in B. Then i need to update A with the ID’s of the rows I inserted in B while keeping a match between them. There is no other relation between A and B, and no data from A goes into B.
After the insert, B might look like this:
idb col3 col4
----------------------
110 uuuu rrr
111 vvvv ttt
112 aaaa www
113 bbbb mmm
After the update of A, A will look like this for example:
ida col1 col2 idb
---------------------------
1 xxxx foo 112
2 yyyy bar 113
Now the question is, how do I determine which record from B corresponds to which from A since I have no relations between them? I could insert and update one by one in a loop but for a lot of records this could be problematic.
Is there a way to do this in fewer steps?
Based upon your requirement this is what you can try to achieve the result