日期:2014-05-18  浏览次数:20470 次

在查询分析器里可以,在程序运行不行
CREATE   TRIGGER     ICStockBill_transfer   ON   [dbo].[ICStockBill]  
FOR     UPDATE
AS

--审核时自动生成调拨单  
declare   @FOldStatus   int     ,@fstatus   int,@finterid   int

select   @FOldStatus=fstatus,@finterid=finterid   from   deleted--修改前
select     @fstatus=fstatus   from   inserted   --修改后

if   @FOldStatus <> @fstatus--如果修改前后发生变化
begin
if   @FOldStatus=0   --修改改无数据为审核   ,修改前有数据为反审核  
begin
--审核时   如有定义不合单据
select   @finterid=finterid   from   deleted--修改前
if   exists(select   fentryselfa0235   from   icstockbill   a,icstockbillentry   b   where   a.finterid=b.finterid   and   b.fentryselfa0235= 'FFF '   and   a.finterid=@finterid)
exec   kd_InsertTransfer   @finterid
end
else
begin
--反审核时
if   exists(select   finterid   from   icstockbillentry   where   finterid   =@finterid   and   finterid*1000+Fentryid   in
(select   fentryselfd0127*1000+fentryselfd0128   from   icstockbill   a,icstockbillentry   b   where   a.finterid=b.finterid   and   a.ftrantype=41))
BEGIN
RAISERROR( '已生成调拨单,反审核前先删除此单! ',18,18)
return
END

end
end


--问题  
不执行RAISERROR( '已生成调拨单,反审核前先删除此单! ',18,18)


------解决方案--------------------
个人认为
你的问题改成:
在应用程序中怎么提取数据库中的RAISERROR错误消息比较直观