SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO
IF EXISTS (SELECT name FROM sysobjects 
         WHERE name = 'CIZSADBS' AND type = 'P')
   DROP PROCEDURE RPTUSER.CIZSADBS
GO


CREATE PROCEDURE RPTUSER.CIZSADBS
@P_SA_ID CHAR(10), 
@P_FREEZE_DTTM CHAR(23), 
@P_ARS_DT CHAR(10),
@P_SW CHAR

AS

/******************************************************************************
   NAME:       CIZSADBS
   PURPOSE:    

******************************************************************************/
BEGIN

    SELECT 
        A.SA_ID,
        A.ARS_DT,
        A.FREEZE_DTTM,
        A.FT_TYPE_FLG, A.SIBLING_ID,
        A.FT_ID,
        A.CUR_AMT,
        A.TOT_AMT,
        A.CURRENCY_CD,
        B.CUR_SYMBOL,
        B.DECIMAL_POSITIONS,
        B.SCALE_POSITIONS,
        B.CUR_POS_FLG
    FROM   
        CI_FT A, 
        CI_CURRENCY_CD B
    WHERE  
        A.SA_ID = @P_SA_ID
        AND  A.REDUNDANT_SW='N'
        AND  A.CUR_AMT>0
        AND  A.FREEZE_SW='Y'
        AND  A.NOT_IN_ARS_SW<>'Y'
        AND(A.FREEZE_DTTM <= CONVERT(CHAR(10),@P_FREEZE_DTTM,101)
            OR ( A.ARS_DT IS NOT NULL AND  A.ARS_DT <= CONVERT(CHAR(10),@P_ARS_DT,101)
              AND 'Y' = @P_SW))
        AND  A.CURRENCY_CD = B.CURRENCY_CD
			 
RETURN

END



GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

