22,210
社区成员
发帖
与我相关
我的任务
分享
ALTER TRIGGER [ICStockBillEntry_INCK24]
ON [dbo].[ICStockBillEntry] /*icstockbill出入库单表体表 */
for insert,update
as
select 1 from inserted a
left join ICStockBill b /*ICStockBill出入库单表头表 */
on a.finterid=b.finterid /* finterid为出入库单表头和表体两张表的关联内码 */
where b.ftrantype=24 /* ftrantype为出入库单表头表的单据类型字段,ftrantype=24即单据类型为领料单 */
and (a.fscstockid=335 or a.fscstockid=338)
if EXISTS(
select 1 from inserted a
left join ICStockBill b /*ICStockBill出入库单表头表 */
on a.finterid=b.finterid /* finterid为出入库单表头和表体两张表的关联内码 */
where b.ftrantype=24 /* ftrantype为出入库单表头表的单据类型字段,ftrantype=24即单据类型为领料单 */
and (a.fscstockid=335 or a.fscstockid=338)) /*出入库单表体的仓库内码,fscstockid=335即原料仓,
fscstockid=338为配件仓 */
begin
rollback tran
raiserror('收料仓库不是周转仓,无法保存!',16,1) with seterror
end
看着没什么问题,像我这样在触发器里面吧数据查询出来,吧结果发来看看