Hi
Can anyone help on rollback and commit transaction
If the procedure excute correct need to out value 1 else 0
ALTER proc [dbo].[gsp_SaveScripts]
(
@CampaignScriptTypeID int = NULL,
@DataElementID int =NULL,
@Script varchar(max)= NULL,
@UserID int =NULL,
@CreateDate datetime = NULL,
@UpdateDate Datetime = NULL,
@Opening varchar(max)= NULL,
@VoiceMail varchar(max)= NULL,
@QualityAssurance varchar(max)= NULL
)
As
BEGIN
declare @Out int
BEGIN TRAN
if Exists(Select * from Scripts(nolock) where CampaignScriptTypeID=@CampaignScriptTypeID and DataElementID=@DataElementID)
Begin
Update Scripts Set
Opening=@Opening,VoiceMail=@VoiceMail,QualityAssurance=@QualityAssurance
where CampaignScriptTypeID=@CampaignScriptTypeID
Update Scripts Set Script=@Script,UpdateDate=getdate()
where CampaignScriptTypeID=@CampaignScriptTypeID and DataElementID=@DataElementID
End
else
Begin
Insert Into Scripts(CampaignScriptTypeID,DataElementID,Script,UserID,CreateDate,UpdateDate,VoiceMail,QualityAssurance,Opening)
Values(@CampaignScriptTypeID,@DataElementID,@Script,@UserID,GETDATE(),GETDATE(),@VoiceMail,@QualityAssurance,@Opening)
End
IF @@ERROR <> 0
ROLLBACK TRAN
ELSE COMMIT TRAN
PRINT @@TRANCOUNT
END