Modifying data stored procedures involves transaction processing.
Last Update:2018-12-07
Source: Internet
Author: User
Alter proc proc_updateinfomation (@ c_id varchar (50), @ State int output)
As
Begin
Declare @ Tran varchar (50)
Set @ State = 0
Begin Tran @ tran
Delete from companyinfo where c_id = @ c_id
If @ error0 or @ rowcount> 1
Begin
Rollback Tran @ tran
Set @ State = 0
End
Delete from enterprisecontent where c_id = @ c_id
If @ error0 or @ rowcount> 1
Begin
Rollback Tran @ tran
Set @ State = 0
End
Insert into companyinfo ([c_id], [companyName], [genderid], [introduce], [logopath], [companypath], [purchaseproduct], [mainproduct], [dealtype], [companytype], [sort], [sortorder], [regmoney], [regtime], [regplace], [companyadderss], [foundtime], [pperson], [limit X], [pdept], [pduty], [paddress], [pzip], [ptel], [pemail], [pPhone], [pmobile], [pfax], [Pqq], [pmsn], [pwebsite], [keyword], [keystarttime], [keyendtime], [addtime], [scores], [award], [ispass], [passtime], [passadmin], [openedmonth], [ispayment], [isdelete]) select [c_id], [companyName], [genderid], [introduce], [logopath], [companypath], [purchaseproduct], [mainproduct], [dealtype], [companytype], [sort], [sortorder], [regmoney], [regtime], [regplace], [companyadderss], [foundtime], [pperson], [partition X], [pdept], [pduty], [paddress], [pzip], [ptel], [pemail], [pPhone], [pmobile], [pfax], [Pqq], [pmsn], [pwebsite], [keyword], [keystarttime], [keyendtime], [addtime], [scores], [award], [ispass], [passtime], [passadmin], [openedmonth], [ispayment], [isdelete] From updatecompanyinfo where c_id = @ c_id
If @ error0 or @ rowcount> 1
Begin
Rollback Tran @ tran
Set @ State = 0
End
Insert into iseisecontent ([c_id], [legalperson], [Worker num], [workernum], [income], [mainmarket], [mainplace], [isoem], [plantarea], [BrandName], [turnover], [import], [Export], [qualitycontrol], [managementsystem], [ourbank], [bankaccount]) select [c_id], [legalperson], [Worker num], [workernum], [income], [mainmarket], [mainplace], [isoem], [plantarea], [BrandName], [turnover], [import], [Export], [qualitycontrol], [managementsystem], [ourbank], [bankaccount] From updatecompanyinfo where c_id = @ c_id
If @ error0 or @ rowcount> 1
Begin
Rollback Tran @ tran
Set @ State = 0
End
Delete from updatecompanyinfo where c_id = @ c_id
If @ error0 or @ rowcount> 1
Begin
Rollback Tran @ tran
Set @ State = 0
End
If @ error = 0 and @ rowcount> 0
Begin
Commit Tran @ tran
Set @ State = 1
End
Else
Begin
Rollback Tran @ tran
Set @ State = 0
End
End
Go