c# - 如何使用 where not exists 向 Oracle 中插入数据?
问题描述
当我使用此代码时,它返回错误“SQL 命令未正确结束” - 我错过了什么?
cmd.CommandText = "insert into trf_urun_bırım_detay " +
"values ('838', '1198385027', '950', '034') " +
"where not exists(select * from trf_urun_bırım_detay where transfer_no = '838')";
解决方案
您的 SQL 语句不正确。您要么必须使用MERGE
语句,要么将 sql 语句更改为以下内容:
insert into trf_urun_bırım_detay (transfer_no , Field2, Field3, Field4)
select '838','1198385027','950','034'
from dual where not exists(select * from trf_urun_bırım_detay where transfer_no = '838');
我已经使用Field2,Field3,Field4
了你的字段,因为你没有提到他们的名字。
推荐阅读
- python - 有没有办法在python中返回一个目录?
- angular - Angular - 多个 NGClass 值相互抵消
- java - 如何使用java从docker容器中读取文件
- android-studio - 我没有在 android studio 中弹出获取依赖项,已经重新安装了项目,所有 sdk 工具都是最新的
- c++ - 构建 levmar.h 库
- google-apps-script - 谷歌脚本给出“意外错误”,没有其他信息
- python-3.x - 格式说明符中具有变量的 f 字符串
- javascript - 有人知道是否有已知的 LibreOffice Impress API 用于读取和呈现演示文件吗?
- azure-devops - SQL Server 需要从 azure 管道中的不同 azure 服务连接访问
- python - ib_insync 客户端 - 对等关闭连接