我读过
here,语法如下:
INSERT WHEN ([Condition]) THEN INTO [TableName] ([ColumnName]) VALUES ([VALUES]) ELSE INTO [TableName] ([ColumnName]) VALUES ([VALUES]) SELECT [ColumnName] FROM [TableName];
但我不想从另一个表中提供值.我只想打字,所以我得到:
INSERT WHEN EXISTS (SELECT 1 FROM FOO WHERE NAME = 'JOE') THEN INTO BAR (NAME,AGE) VALUES ('JOE',50)
这会产生异常:ORA-00928:缺少SELECT关键字.
如果在另一个表中找到给定值,我想执行插入.
解决方法@H_403_14@
使用选择也运行.但是关键字值存在问题
INSERT
WHEN EXISTS (SELECT 1 FROM FOO WHERE NAME = 'JOE')
THEN
INTO BAR (NAME,AGE)
SELECT 'JOE',50 FROM DUAL
INSERT WHEN EXISTS (SELECT 1 FROM FOO WHERE NAME = 'JOE') THEN INTO BAR (NAME,AGE) SELECT 'JOE',50 FROM DUAL