我在这里读到语法如下所示:
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关键字.
如果在另一个表中找到给定值,我想执行插入.
使用选择也运行.但是关键字值存在问题
INSERT WHEN EXISTS (SELECT 1 FROM FOO WHERE NAME = 'JOE') THEN INTO BAR (NAME, AGE) SELECT 'JOE', 50 FROM DUAL