日期:2014-05-17  浏览次数:20646 次

请问,这段代码怎么加事务?有几种办法。
如题:我自己的办法是下面代码,不知道对否,请大家看看,
或者有别的代码没?
USE [LAPSBase]
GO
/****** Object:  StoredProcedure [dbo].[Pro_LAPS_InsertApproveReport]    Script Date: 11/22/2012 14:19:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[Pro_LAPS_InsertApproveReport]
@CIFNm nvarchar(50),
@ACNo nvarchar(50),
@CreditNo nvarchar(50),

-------系统字段-----
@PledgeType nvarchar(50),
@Cr_POBCType nvarchar(50),
@Cr_POBCRemark nvarchar(50),
@Cr_FQIZHANType nvarchar(50),
@Cr_FQIZHANMark nvarchar(50),
@Cr_GeRenDianhuaHecha nvarchar(50),
@Cr_GeRenDianhuaType nvarchar(50),
@Cr_GerenJuzhuDIType nvarchar(50),
@Cr_GerenJuzhuDITypeMark nvarchar(50),
@Cr_DTIType nvarchar(50),
@Cr_DTI nvarchar(50),
@Cr_CsmFinaFlowType nvarchar(50),
@CR_CsmFinaFlowExAmount nvarchar(50),
@CR_CsmFinaFlowExMonth nvarchar(50),
@CR_CsmFinaFlowExEvaluate nvarchar(50),
@Mo_MoType nvarchar(50),
@Mo_Yuguzhi nvarchar(50),
@Mo_Zhengshiguzhi nvarchar(50),
@Mo_DiYachengshu nvarchar(50),
@Mo_DiYaAmount nvarchar(50),
@Mo_DiyajineTotal nvarchar(50),
@Mo_MoMark nvarchar(50),
@Approvelimits nvarchar(50),
@Cons_ProductCode nvarchar(50),
@Cons_IsApproveCondition nvarchar(50),
@Cons_NormalPasson nvarchar(50),
@Cons_AttenionResume nvarchar(50),
@Cons_MoName nvarchar(50),
@Cons_RefuseValue nvarchar(50),
----定义从表-审批意见的参数----
@OperCode nvarchar(50),
@OperIdeas nvarchar(50),
----定义从表-财务参数----
@Fn_FileType nvarchar(50),
@Fn_CheckPeriodStart nvarchar(50),
@Fn_CheckPeriodEnd nvarchar(50),
@Fn_Income nvarchar(50),
@Fn_PayAmout nvarchar(50),
@Fn_ValidityType nvarchar(50),
@Fn_Remark nvarchar(50)


AS
BEGIN

SET XACT_ABORT ON 

begin tran
     insert into ApproveReprotMain
     (
CIFNm,
ACNo,
CreditNo,
PledgeType,
Cr_POBCType,
Cr_POBCRemark,
Cr_FQIZHANType,
Cr_FQIZHANMark,
Cr_GeRenDianhuaHecha,
Cr_GeRenDianhuaType,
Cr_GerenJuzhuDIType,
Cr_GerenJuzhuDITypeMark,
Cr_DTIType,
Cr_DTI,
Cr_CsmFinaFlowType,
CR_CsmFinaFlowExAmount,
CR_CsmFinaFlowExMonth,
CR_CsmFinaFlowExEvaluate,
Mo_MoType,
Mo_Yuguzhi,
Mo_Zhengshiguzhi,
Mo_DiYachengshu,
Mo_DiYaAmount,
Mo_DiyajineTotal,
Mo_MoMark,
Approvelimits,
Cons_ProductCode,
Cons_IsApproveCondition,
Cons_NormalPasson,
Cons_AttenionResume,
Cons_MoName,
Cons_RefuseValue
     )
     values 
     (
@CIFNm,
@ACNo,
@CreditNo,
@PledgeType,
@Cr_POBCType,
@Cr_POBCRemark,
@Cr_FQIZHANType,
@Cr_FQIZHANMark,
@Cr_GeRenDianhuaHecha,
@Cr_GeRenDianhuaType,
@Cr_GerenJuzhuDIType,
@Cr_GerenJuzhuDITypeMark,
@Cr_DTIType,
@Cr_DTI,
@Cr_CsmFinaFlowType,
@CR_CsmFinaFlowExAmount,
@CR_CsmFinaFlowExMonth,
@CR_CsmFinaFlowExEvaluate,
@Mo_MoType,
@Mo_Yuguzhi,
@Mo_Zhengshiguzhi,
@Mo_DiYachengshu,
@Mo_DiYaAmount,
@Mo_DiyajineTotal,
@Mo_MoMark,
@Approvelimits,
@Cons_ProductCode,
@Cons_IsApproveCondition,
@Cons_NormalPasson,
@Cons_Atten