oracle 查询有什么问题,如何纠正错误?[副本]

ct3nt3jp  于 2023-04-29  发布在  Oracle
关注(0)|答案(1)|浏览(145)

此问题已在此处有答案

Best way to do multi-row insert in Oracle?(9个回答)
4天前关闭。

INSERT ALL INTO ITDEV.COM_CATEGORY_TB (CAT_CODE,CAT_DESCRIPTION,CREATED_ON,CREATED_BY,UPDATED_ON,UPDATED_BY) VALUES
     (1001,'Cost Savings',TIMESTAMP'2010-12-14 00:00:00.0','SESH',NULL,NULL),
     (1002,'Business Improvements',TIMESTAMP'2010-12-14 00:00:00.0','SESH',TIMESTAMP'2011-01-17 09:03:22.0','TEMP1'),
     (1003,'Health and Wellness',TIMESTAMP'2010-12-14 00:00:00.0','SESH',TIMESTAMP'2011-01-21 13:18:23.0','TEMP1'),
     (1004,'Complaints',TIMESTAMP'2010-12-14 00:00:00.0','SESH',TIMESTAMP'2011-01-12 09:34:42.0','SESH'),
     (1005,'Others',TIMESTAMP'2010-12-14 00:00:00.0','SESH',TIMESTAMP'2011-01-12 11:06:43.0','SESH')
    SELECT * FROM dual;

输出SQL错误[928] [42000]:ORA-00928:缺少SELECT关键字
我也试着这样做:

INSERT ALL 
INTO ITDEV.COM_CATEGORY_TB (CAT_CODE,CAT_DESCRIPTION,CREATED_ON,CREATED_BY,UPDATED_ON,UPDATED_BY) VALUES
     (1001,'Cost Savings',TIMESTAMP'2010-12-14 00:00:00.0','SESH',NULL,NULL)
INTO ITDEV.COM_CATEGORY_TB (CAT_CODE,CAT_DESCRIPTION,CREATED_ON,CREATED_BY,UPDATED_ON,UPDATED_BY) VALUES
     (1002,'Business Improvements',TIMESTAMP'2010-12-14 00:00:00.0','SESH',TIMESTAMP'2011-01-17 09:03:22.0','TEMP1')
INTO ITDEV.COM_CATEGORY_TB (CAT_CODE,CAT_DESCRIPTION,CREATED_ON,CREATED_BY,UPDATED_ON,UPDATED_BY) VALUES
     (1003,'Health and Wellness',TIMESTAMP'2010-12-14 00:00:00.0','SESH',TIMESTAMP'2011-01-21 13:18:23.0','TEMP1')
INTO ITDEV.COM_CATEGORY_TB (CAT_CODE,CAT_DESCRIPTION,CREATED_ON,CREATED_BY,UPDATED_ON,UPDATED_BY) VALUES
     (1004,'Complaints',TIMESTAMP'2010-12-14 00:00:00.0','SESH',TIMESTAMP'2011-01-12 09:34:42.0','SESH')
INTO ITDEV.COM_CATEGORY_TB (CAT_CODE,CAT_DESCRIPTION,CREATED_ON,CREATED_BY,UPDATED_ON,UPDATED_BY) VALUES
     (1005,'Others',TIMESTAMP'2010-12-14 00:00:00.0','SESH',TIMESTAMP'2011-01-12 11:06:43.0','SESH')
    SELECT * FROM dual;

但我得到了这样的输出:

SQL Error [4091] [42000]: ORA-04091: table ITDEV.COM_CATEGORY_TB is mutating, trigger/function may not see it
ORA-06512: at "ITDEV.COM_CATEGORY_TR", line 4
ORA-04088: error during execution of trigger 'ITDEV.COM_CATEGORY_TR'
zd287kbt

zd287kbt1#

您可以按以下方式执行此操作:

INSERT INTO ITDEV.COM_CATEGORY_TB (CAT_CODE,CAT_DESCRIPTION,CREATED_ON,CREATED_BY,UPDATED_ON,UPDATED_BY)
select 1001,'Cost Savings',TIMESTAMP'2010-12-14 00:00:00.0','SESH',NULL,NULL from dual union all
select 1002,'Business Improvements',TIMESTAMP'2010-12-14 00:00:00.0','SESH',TIMESTAMP'2011-01-17 09:03:22.0','TEMP1' from dual union all
select 1003,'Health and Wellness',TIMESTAMP'2010-12-14 00:00:00.0','SESH',TIMESTAMP'2011-01-21 13:18:23.0','TEMP1' from dual union all
select 1004,'Complaints',TIMESTAMP'2010-12-14 00:00:00.0','SESH',TIMESTAMP'2011-01-12 09:34:42.0','SESH' from dual union all
select 1005,'Others',TIMESTAMP'2010-12-14 00:00:00.0','SESH',TIMESTAMP'2011-01-12 11:06:43.0','SESH' from dual;1-01-21 13:18:23.0','TEMP1' from dual;

相关问题