在SQL DBMS中,select-test-
insert方法是一个错误:没有什么可以阻止另一个进程在您的
select和
insert语句之间插入“缺少”行。改为执行此操作:
insert into mytable (color, brightness, size, age)select color, brightness, size, age from mytablewhere not exists ( select 1 from from mytable where color = 'X' and brightness = 'Y');SELECt (color, brightness, size, age) FROM mytable WHERe color = 'X' AND brightness= 'Y';
您应该能够将整个文本作为单个“查询”传递给DBMS。您可能要考虑使其成为存储过程。



