货品资料表如下:
prd_no up_max
5200703 1.7
6300509 2.1
5700626 0.8
........................................
..........................................
采购单字段如下
prd_no up
怎样实现录入采购单时对应的prd_no的up值大于up_max不能保存
------解决思路----------------------
要是数据库用触发器。插入之前验证。
------解决思路----------------------
只能后台的话,加触发器,大于则抛出异常
create trigger trigger_update
on test_updaterecord
for update
as
begin
if 这里进行判断
begin
rollback transaction
end
end
------解决思路----------------------
if exists (select up_max from inserted as a join tablename as b on a.prd_no=b.prd_no and a.up_max>b.up_max)
rollback
--建议你搜下INSERTED表 看看例子就懂了