I have an issue with migration of data in Oracle DB during some release upgrades.
Case:
- Table X in release 1 has three coulmns.
- Same Table X in release 2 has five columns(two added in release 2).
- Same table in release 3 has five columns as in release 2.
- Upgrade paths include Release 1 to Release 3 and Release 2 to Release 3.
I need a Oracle SQL query which copies data from a TMP table to actual table in both cases based on coulmns size from TMP where i have stored the data temporarily(this has to be done).
Below is the query which i tried but it isnt working.
insert into USER.X values (CASE (select count(*) from all_tab_columns where table_name='TMP') WHEN '3' THEN (select USER.TMP.*, null NEWCOL1 from USER.TMP, null NEWCOL2 from USER.TMP) WHEN '5' THEN (select USER.TMP.* from USER.TMP) END ); Please help in this regard and if there is a better way of doing the same please let me know.
values (a,b,c);useselect a,b,c from dual;