本文介绍了如何执行此程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何执行以下插入更新程序
How to execute below procedure for insert update
create procedure InsertData
as begin
declare @Result as int,@segment varchar(3), @tradeID bigint = null,@accountID varchar(20),
@symbol1 varchar(20),@tradedqty bigint,@tradeprice money,
@transtype int,@tradetime varchar(20),@traderID bigint,
@locationID varchar(25),@orderentrytime varchar(20),
@process1 int,@isin varchar(20)
exec CheckUniqueTradeID @segment,null,@accountID,@symbol1,@tradedqty,@tradeprice,@transtype,
@tradetime,@traderID,@locationID,@orderentrytime,@process1,@isin,@Result out
if @Result = 1
begin
insert into [dbo].[consolidated](segment,tradeID,accountID,symbol1,
tradedqty,tradeprice,transtype,tradetime,traderID,locationID,
tradevalue,orderentrytime,process1,isin)
select [segment],
CONVERT(VARCHAR(10),[tradeID])+[transtype] AS NewTrans,
[accountID],
[symbol]
,[tradedqty],
CASE WHEN [process1] = 1 THEN [tradeprice]/100 END AS [tradeprice],
case when [process1] =1 then case when [transtype] = 'B' THEN 1 WHEN [transtype] = 'S' THEN 2 end
end AS [transtype],
[tradetime1],
[traderID],
[locationID],
CASE WHEN [process1] = 0 THEN [tradedqty]*[tradeprice]
END AS [tradevalue],
[orderentrytime],
CASE WHEN [process1] = 0 THEN 1 ELSE 0 END AS [process1],
[isin]
from [dbo].[bse_trade] where process1 = 0
end
if @Result = 0
begin
exec UpdateParameters
end
update bse_trade set process1 = 2
where process1 = 1
end
推荐答案
EXEC InsertData
更多信息: []
这篇关于如何执行此程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!