太长了
多行可以不必用游标处理.
只要表有主键可以用笔的连接解决,以下是示意性的,可能和你的实际不一样:update yg_stock
set yg_stock.num = yg_stock.num + inserted.num-deleted.num
from inserted,yg_stock,deleted
where yg_stock.tobac_store_cd = inserted.tobac_store_cd
and inserted.tobac_store_cd = deleted.tobac_store_cd
and ..... -----这里写可能 的连接条件insert into yg_stock
select
inserted.tobac_store_cd,
inserted.num - deleted.num
from inserted,deleted
where inserted.tobac_store_cd = deleted.tobac_store_cd
and ..... -----这里写可能 的连接条件
and not exists (
select * from yg_stock
where inserted.tobac_store_cd = yg_stock.tobac_store_cd
and ..... -----这里写可能 的连接条件
)
多行可以不必用游标处理.
只要表有主键可以用笔的连接解决,以下是示意性的,可能和你的实际不一样:update yg_stock
set yg_stock.num = yg_stock.num + inserted.num-deleted.num
from inserted,yg_stock,deleted
where yg_stock.tobac_store_cd = inserted.tobac_store_cd
and inserted.tobac_store_cd = deleted.tobac_store_cd
and ..... -----这里写可能 的连接条件insert into yg_stock
select
inserted.tobac_store_cd,
inserted.num - deleted.num
from inserted,deleted
where inserted.tobac_store_cd = deleted.tobac_store_cd
and ..... -----这里写可能 的连接条件
and not exists (
select * from yg_stock
where inserted.tobac_store_cd = yg_stock.tobac_store_cd
and ..... -----这里写可能 的连接条件
)
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货