[英]Migration of Data in Oracle DB using SQL
I have an issue with migration of data in Oracle DB during some release upgrades. 在某些版本升级期间,Oracle数据库中的数据迁移存在问题。
Case: 案件:
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). 我需要一个Oracle SQL查询,在这两种情况下,都将根据我临时存储数据的TMP的库仑大小将数据从TMP表复制到实际表(必须这样做)。
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. 请在这方面提供帮助,如果有更好的方法,请告诉我。
Edit: There are multiple problems in you logic. 编辑:您的逻辑中存在多个问题。
too many values
不仅如此,您还会得到错误的too many values
So you should 所以你应该
Execute immidiate
通过Execute immidiate
Prev. 上一个 Response 响应
The first problem in your query is that select count(*) from all_tab_columns where table_name='TMP'
returns an integer, whereas in case
you are comparing it to '3'
and '5'
as varchar. 查询中的第一个问题是select count(*) from all_tab_columns where table_name='TMP'
返回一个整数,而case
您将其与varchar比较为'3'
和'5'
。 So assuming that rest of your query return result correctly, try replacing '3'
and '5'
as 3
and 5
因此,假设查询的其余部分正确返回了结果,请尝试将'3'
和'5'
替换为3
和5
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.