太长了
多行可以不必用游标处理.
只要表有主键可以用笔的连接解决,以下是示意性的,可能和你的实际不一样: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 .....                       -----这里写可能 的连接条件
)