Y
_yzy_
Unregistered / Unconfirmed
GUEST, unregistred user!
在执行一个存储过程的时候,如果存储过程发生错误,或存储过程执行成功但所影响的触发器由于约束或别的原因没有执行成功,整个存储过程会生成回滚,但用try except end 结构捕捉不到异常。难道在触发器或存储过程中还要设置什么异常返回吗?DM.ACN.BeginTrans; try DM.ACN.Execute('exec SP_Input 23'); //调用存储过程 DM.ACN.CommitTrans; //如果事务执行不成功会回滚,但不触发Except,而是继续执行下面的过帐成功信息 MSB(由于以下原因过帐成功!,2); ..... except on E:exception do begin DM.ACN.RollbackTrans; MSB('由于以下原因过帐失败!'+#10+#13+E.Message,2); end; end;上面DM和ACN的定义: TDM = class(TDataModule) ACN: TADOConnection;-------------------------示例触发器:Create Trigger ReportedLossList_TR on ReportedLossListfor insert,update,deleteas UPDATE RawMaterials_T SET BQBS=(SELECT ISNULL(SUM(R_Number),0) FROM ReportedLossList Where (R_ID=RawMaterials_T.R_ID) AND (Sell_Date>ISNUll(RawMaterials_T.PDDate,'1900-01-01 00:00:00')) AND (Del_Flag='0')) UPDATE RawMaterials_T SET BQZC=SQKC+(BQGJ-BQInTH)-(BQSell-BQSellTh)-BQBSGO