------------------------------------------------------------------
--                                                              --
--  File:   Isolation4_S2.SQL                                   --
--          Microsoft TPC-E Benchmark Kit Ver. 1.12.0-1025      --
--          Copyright Microsoft  2010, 2011, 2012               --
--                                                              --
--  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    = 43006406594,          ---****** CUSTOMER ACCOUNT ID FROM ISOLATION4_S1 OUTPUT
        @trade_id   = 200042103020001       ---****** 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
