Guest User

Untitled

a guest
Nov 20th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. table_id (PK) number;
  2. table_1_id number;
  3. table_2_id number;
  4.  
  5. table_id number;
  6. table_1_id number;
  7. table_2_id number;
  8. table_key number;
  9. table_key_data varchar2(15);
  10.  
  11. table_1_id table_2_id table_id table_key table_key_data
  12. 1 123 12345 1 1111
  13. 1 123 12345 2 ABC
  14.  
  15. 12345
  16. 23456
  17. 34567
  18. ..plus hundreds/thousands more
  19.  
  20. table_1_id table_2_id table_id table_key table_key_data
  21. 1 123 12345 1 1111
  22. 1 123 12345 2 ABC
  23. 1 123 23456 1 1111
  24. 1 123 23456 2 ABC
  25. 1 123 34567 1 1111
  26. 1 123 34567 2 ABC
  27. ...plus remaining hundreds/thousands more.
  28.  
  29. INSERT INTO TABLE_B (SELECT 1,123,TABLE_A.TABLE_ID, 1 for the first record and 2 for second record, CASE WHEN table_key = 1 THEN '1111' WHEN table_key = 2 THEN '1111111' END FROM TABLE_A WHERE TABLE_A.TABLE_ID NOT IN (SELECT table_id FROM TABLE_B)
Add Comment
Please, Sign In to add comment