/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\EB_constraint.sql **/
 EXEC P_ALTERPK 'PK_T_EB_OFFSETRULE_L', 'T_EB_OFFSETRULE_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_OFFSETRULE_L_FID') CREATE INDEX IDX_EB_OFFSETRULE_L_FID ON T_EB_OFFSETRULE_L ( FID );


 EXEC P_ALTERPK 'PK_T_EB_OFFSETRULEACCOUNTS', 'T_EB_OFFSETRULEACCOUNTS', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_OFFSETRULE_ACCOUNTS_FID') CREATE INDEX IDX_EB_OFFSETRULE_ACCOUNTS_FID ON T_EB_OFFSETRULEACCOUNTS ( FID );


 EXEC P_ALTERPK 'PK_T_EB_OFFSETRULEORGS', 'T_EB_OFFSETRULEORGS', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_OFFSETRULEORGS_FID') CREATE INDEX IDX_EB_OFFSETRULEORGS_FID ON T_EB_OFFSETRULEORGS ( FID );


 EXEC P_ALTERPK 'PK_T_EB_OFFSETRULE', 'T_EB_OFFSETRULE', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_OFF_CATALOGID') CREATE INDEX IDX_EB_OFF_CATALOGID ON T_EB_OFFSETRULE ( FOFFSETRULECATALOGID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_OFF_FMODELID') CREATE INDEX IDX_EB_OFF_FMODELID ON T_EB_OFFSETRULE ( FMODELID );


 EXEC P_ALTERPK 'PK_T_EB_OFFSETRULECATALOG', 'T_EB_OFFSETRULECATALOG', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_OFFCATA_FMODEL') CREATE INDEX IDX_EB_OFFCATA_FMODEL ON T_EB_OFFSETRULECATALOG ( FMODELID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_OFFCATA_FNUMBER') CREATE INDEX IDX_EB_OFFCATA_FNUMBER ON T_EB_OFFSETRULECATALOG ( FNUMBER );


 EXEC P_ALTERPK 'PK_T_EB_OFFSETRULECATALOG_L', 'T_EB_OFFSETRULECATALOG_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_OFFCATA_L_FID') CREATE INDEX IDX_EB_OFFCATA_L_FID ON T_EB_OFFSETRULECATALOG_L ( FID );


 EXEC P_ALTERPK 'PK_T_EB_DIMMEMBERHISTORY', 'T_EB_DIMMEMBERHISTORY', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IX_EB_DIMMEMBERHISTORY') CREATE INDEX IX_EB_DIMMEMBERHISTORY ON T_EB_DIMMEMBERHISTORY ( FMODELID ,FBUSINESSDATA ,FDIMENSION ,FBIZNUMBER ,FDIMNUMBER );


 EXEC P_ALTERPK 'PK_T_EB_APPROVETEMPENTRY', 'T_EB_APPROVETEMPENTRY', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BGMD_APPROVEENTITY_FID') CREATE INDEX IDX_BGMD_APPROVEENTITY_FID ON T_EB_APPROVETEMPENTRY ( FID );


EXEC p_DropIdx 'IDX_BGMD_PLANRULE_ACCOUNT', 'T_BGMD_PLANRULE';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BGMD_PLANRULE_ACCOUNT') CREATE INDEX IDX_BGMD_PLANRULE_ACCOUNT ON T_BGMD_PLANRULE ( FACCOUNTID ,FRULEFROM ,FDATATYPEID ,FVERSIONID );

 EXEC P_ALTERPK 'PK_T_EB_APPROVETEMPLATE', 'T_EB_APPROVETEMPLATE', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BGMD_PLANRULE_NUMBER') CREATE INDEX IDX_BGMD_PLANRULE_NUMBER ON T_EB_APPROVETEMPLATE ( FNUMBER );



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