Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. BEGIN
  2. FOR single_row IN (
  3. SELECT *
  4. FROM MY_TABLE)
  5. LOOP
  6. --iterate through columns of 'single_row'
  7. --for each nullable column do insert with real current column name and column value)
  8. --I assume each column is nullable except of ID
  9. INSERT INTO ANOTHER_TABLE VALUES (single_row.id, column_name, column_value);
  10. END LOOP;
  11. END;
  12.  
  13. ID|ABC1|DA23|EE123|...
  14. 1|123|456|789|...
  15. 2|321|654|987|...
  16.  
  17. MY_TABLE_ID|COLUMN_NAME|COLUMN_VALUE
  18. 1|ABC1|123
  19. 1|DA23|456
  20. 1|EE123|789
  21. ... other columns from row 1
  22. 2|ABC1|321
  23. 2|DA23|654
  24. 2|EE123|987
  25. ... other columns from row 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement