----------------------------------------------------------------
--                                                              
--  File:   Isolation4_S2.SQL                                   
--          Microsoft TPC-E Benchmark Kit Ver. 1.14.0-1031      
--          Copyright Microsoft, 2008-2015                  
--                                                              
--  Implements TPC-E Isolation test #1                          
--  P3 Test in Read-Write                                       
--                                                              
----------------------------------------------------------------
USE tpce
GO

BEGIN TRANSACTION

DECLARE @trade_id           bigint,
        @acct_id            bigint,
        @se_amount          numeric(10,2),
        @ca_bal             numeric(12,2)

---------------------------------------------------------
--- replace the account id below with 
--- that returned in the Isolation4_S1 script.
---------------------------------------------------------
SELECT  @acct_id    = 43012669591,          ---****** CUSTOMER ACCOUNT ID FROM ISOLATION4_S1 OUTPUT
        @trade_id   = 200100353800004       ---****** TRADE ID FROM ISOLATION4_S1 OUTPUT


EXEC TradeResult_Iso4   @trade_id,
                        100,
                        @se_amount  OUTPUT


--- get the CA_BAL for the customer account we used
SELECT  @ca_bal = CA_BAL
FROM    CUSTOMER_ACCOUNT
WHERE   CA_ID = @acct_id

PRINT   ' '
PRINT   'Values used in/Returned from Isolation 4 - S2:'
SELECT  @acct_id            As 'Customer Account ID',
        @ca_bal             As 'Customer Account Balance',
        @se_amount          As 'Settlement Amount'

COMMIT
GO
