国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > SQL Server > 正文

動態(tài)SQL中返回數(shù)值的實現(xiàn)代碼

2024-08-31 00:57:45
字體:
供稿:網(wǎng)友

復(fù)制代碼 代碼如下:


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訂單號生成規(guī)則
@webstockflag varchar(10)--web訂單號生成規(guī)則
)
as
set xact_abort on
begin transaction mytrans
begin try
declare @uid int--根據(jù)語句查找用戶ID
declare @execsql varchar(max)
declare @ebayuid int--根據(jù)語句查找用戶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)--執(zhí)行web語句
begin
exec sp_common_WebSiteorder_AddInfo @websql, @webusersql, @webwhere ,@webstockflag
end
if(LEN(@ebaysql)>0)--執(zhí)行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)+'')--必須替換 否則會報錯誤說必須聲明標(biāo)量變量
end
else
begin
set @execebaysql=@ebayusersql+@ebaysql --不存在ebayuid
end
set @execebaysql= REPLACE(@execebaysql,'@00',dbo.GetOrderNum(@ebaystockflag))--調(diào)用函數(shù)替換訂單編號
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

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 娱乐| 武冈市| 保定市| 滦南县| 广安市| 汕尾市| 麻阳| 和顺县| 天津市| 措勤县| 抚松县| 竹溪县| 交口县| 察雅县| 运城市| 贡嘎县| 衡阳县| 桦南县| 洪泽县| 视频| 晋宁县| 军事| 湖州市| 武山县| 勐海县| 东乡族自治县| 衡南县| 东方市| 道真| 综艺| 南岸区| 青岛市| 炎陵县| 卓尼县| 图木舒克市| 尚义县| 宣汉县| 樟树市| 勐海县| 德清县| 上林县|