/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\FA_constraint.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_FA_DEVALUE_ORG') CREATE INDEX IDX_FA_DEVALUE_ORG ON T_FA_ASSET_DEVALUE ( FORGID ,FDEPREUSEID ,FDEVALUEPERIOD );

EXEC p_DropIdx 'IDX_FA_CLRBIL_ORGID', 'T_FA_CLRBILL';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_FA_CLRBIL_ORGID') CREATE INDEX IDX_FA_CLRBIL_ORGID ON T_FA_CLRBILL ( FORGID ,FCLEARDATE );

EXEC p_DropIdx 'IDX_FA_CARREA_FACCDATE', 'T_FA_CARD_REAL';
EXEC p_DropIdx 'IDX_FA_CARREA_FBILLNO', 'T_FA_CARD_REAL';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_FA_CARREA_FACCDATE') CREATE INDEX IDX_FA_CARREA_FACCDATE ON T_FA_CARD_REAL ( FASSETUNITID ,FISBAK ,FREALACCOUNTDATE );
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_FA_CARREA_INI_SEL') CREATE INDEX IDX_FA_CARREA_INI_SEL ON T_FA_CARD_REAL (FASSETUNITID,  FISINITIALCARD,FNUMBER);

/*IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_FA_CF_FORGID') CREATE INDEX IDX_FA_CF_FORGID ON T_FA_CARD_FIN ( FORG ,FBILLSTATUS );
EXEC p_DropIdx 'IDX_FA_CF_FORGID', 'T_FA_CARD_FIN';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_FA_CF_MAINPAGE') CREATE INDEX IDX_FA_CF_MAINPAGE ON T_FA_CARD_FIN ( FASSETBOOKID ,FCLEARPERIODID );
EXEC p_DropIdx 'IDX_FA_CF_MAINPAGE', 'T_FA_CARD_FIN';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_FA_CF_FASSETCAT') CREATE INDEX IDX_FA_CF_FASSETCAT ON T_FA_CARD_FIN ( FASSETCATID ,FORG ,FENDPERIODID );
EXEC p_DropIdx 'IDX_FA_CF_FASSETCAT', 'T_FA_CARD_FIN';*/
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_FINCARD_PERIOD') CREATE INDEX IDX_FINCARD_PERIOD ON T_FA_CARD_FIN ( FORG ,FDEPREUSEID ,FPERIODID );
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_FINCARD_DATE') CREATE INDEX IDX_FINCARD_DATE ON T_FA_CARD_FIN (FORG,FDEPREUSEID,FFINACCOUNTDATE,FNUMBER);

IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_FA_DEPREENTRY_FDETAILSID') CREATE INDEX IDX_FA_DEPREENTRY_FDETAILSID ON T_FA_DEPREDETAILENTRY ( FDETAILSID );
EXEC p_DropIdx 'IDX_FA_DEPREENTRY_FDETAILSID', 'T_FA_DEPREDETAILENTRY';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_FA_DEPREENTRY_DETAILS_FFID') CREATE INDEX IDX_FA_DEPREENTRY_DETAILS_FFID  ON T_FA_DEPREDETAILENTRY ( FDETAILSID ,FFINCARDID );


/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\FA_constraint.sql **/
