ALTER proc [dbo].[sp_common_paypal_AddInfo]
(
@paypalsql varchar(max),-- paypalsql
@paypalusersql varchar(max),--paypal sql
@ebaysql varchar(max),-- ebaysql
@ebayusersql varchar(max),--ebay sql
@paypaluserwhere varchar(max),--paypal ID
@ebayuserwhere varchar(max),--ebay ID
@websql varchar(max),--web sql
@webusersql varchar(max),--web sql
@webwhere varchar(max),--web where sql
@ebaystockflag varchar(10),--ebay
@webstockflag varchar(10)--web
)
as
set xact_abort on
begin transaction mytrans
begin try
declare @uid int-- ID
declare @execsql varchar(max)
declare @ebayuid int-- ID
declare @execebaysql nvarchar(max)-- sp_executesql nvarchar
declare @sql nvarchar(max)-- sp_executesql nvarchar
set @sql='select @a=ID from tb_TransactionCustomer where '+ convert(varchar(8000),@paypaluserwhere)
exec sp_executesql @sql,N'@a int output',@uid output
set @uid =ISNULL(@uid,0)-- null len()
-- paypal id
if(@uid>0)
begin
set @execsql=@paypalsql--
set @execsql= REPLACE(@execsql,'@uid',''+convert(varchar,@uid)+'')
end
else
begin
set @execsql=@paypalusersql+@paypalsql --
end
if(LEN(@websql)>0)-- web
begin
exec sp_common_WebSiteorder_AddInfo @websql, @webusersql, @webwhere ,@webstockflag
end
if(LEN(@ebaysql)>0)-- ebay
begin
--exec sp_common_Ebay_AddInfo @ebaysql, @ebayusersql, @ebayuserwhere ,@ebaystockflag
SELECT * FROM tb_EbayOrder WITH (TABLOCKX)
SELECT * FROM tb_EbayOrderList WITH (TABLOCKX)
SELECT * FROM tb_EbayOrderUserInfo WITH (TABLOCKX)
set @sql='select @b=ID from tb_EbayOrderUserInfo where '+ convert(varchar(8000),@ebayuserwhere)
exec sp_executesql @sql,N'@b int output',@ebayuid output
set @ebayuid =ISNULL(@ebayuid,0)
if(@ebayuid>0)
begin
set @execebaysql=@ebaysql-- ebayuid
set @execebaysql= REPLACE(@execebaysql,'@ebayuid',''+convert(varchar,@ebayuid)+'')--
end
else
begin
set @execebaysql=@ebayusersql+@ebaysql -- ebayuid
end
set @execebaysql= REPLACE(@execebaysql,'@00',dbo.GetOrderNum(@ebaystockflag))--
exec (@execebaysql)
end
exec(@execsql)
end try
begin catch
if(@@TRANCOUNT>0)
rollback transaction mytrans
end catch
if(@@TRANCOUNT>0)
begin
commit transaction mytrans
end
else begin
rollback transaction mytrans
end