/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\BCM_constraint.sql **/
 EXEC P_ALTERPK 'PK_T_BCM_SCENEPERIOD', 'T_BCM_SCENEPERIOD', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_T_BCM_MEMBOFMYCOMPANY', 'T_BCM_MEMBOFMYCOMPANY', 'FID', '1';

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


 EXEC P_ALTERPK 'PK_T_BCM_MEMBOFMYCOMPANY_L', 'T_BCM_MEMBOFMYCOMPANY_L', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_T_BCM_STRUCTOFMYCOMPANY_L', 'T_BCM_STRUCTOFMYCOMPANY_L', 'FPKID', '1';

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


EXEC p_DropIdx 'IDX_BCM_RPTLIST_DIMCOMBIE', 'T_BCM_REPORTLIST';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_BCM_REPORTLIST_GP') CREATE INDEX IDX_T_BCM_REPORTLIST_GP ON T_BCM_REPORTLIST ( FSTATUS ,FGROUPID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_FY_DIM') CREATE INDEX IDX_BCM_FY_DIM ON T_BCM_STRUCTOFFY ( FDIMENSIONID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_FY_PARENT') CREATE INDEX IDX_BCM_FY_PARENT ON T_BCM_STRUCTOFFY ( FPARENTID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_PREIOD_DIM') CREATE INDEX IDX_BCM_PREIOD_DIM ON T_BCM_STRUCTOFPERIOD ( FDIMENSIONID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_PREIOD_PARENT') CREATE INDEX IDX_BCM_PREIOD_PARENT ON T_BCM_STRUCTOFPERIOD ( FPARENTID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_BP_DIM') CREATE INDEX IDX_BCM_BP_DIM ON T_BCM_STRUCTOFPROCESS ( FDIMENSIONID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_BP_PARENT') CREATE INDEX IDX_BCM_BP_PARENT ON T_BCM_STRUCTOFPROCESS ( FPARENTID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_RULE_DIM') CREATE INDEX IDX_BCM_RULE_DIM ON T_BCM_STRUCTOFRULE ( FDIMENSIONID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_RULE_PARENT') CREATE INDEX IDX_BCM_RULE_PARENT ON T_BCM_STRUCTOFRULE ( FPARENTID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_ICENTITY_DIM') CREATE INDEX IDX_BCM_ICENTITY_DIM ON T_BCM_STRUCTOFICENTITY ( FDIMENSIONID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_ICENTITY_PARENT') CREATE INDEX IDX_BCM_ICENTITY_PARENT ON T_BCM_STRUCTOFICENTITY ( FPARENTID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_EB_VERSION_DIM') CREATE INDEX IDX_BCM_EB_VERSION_DIM ON T_BCM_STRUCTOFVERSION ( FDIMENSIONID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_EB_VERSION_PARENT') CREATE INDEX IDX_BCM_EB_VERSION_PARENT ON T_BCM_STRUCTOFVERSION ( FPARENTID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_DATASORT_DIM') CREATE INDEX IDX_BCM_DATASORT_DIM ON T_BCM_STRUCTOFDATASORT ( FDIMENSIONID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_DATASORT_PARENT') CREATE INDEX IDX_BCM_DATASORT_PARENT ON T_BCM_STRUCTOFDATASORT ( FPARENTID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_DATETYPE_DIM') CREATE INDEX IDX_BCM_DATETYPE_DIM ON T_BCM_STRUCTOFDATETYPE ( FDIMENSIONID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_DATETYPE_PARENT') CREATE INDEX IDX_BCM_DATETYPE_PARENT ON T_BCM_STRUCTOFDATETYPE ( FPARENTID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_AT_DIM') CREATE INDEX IDX_BCM_AT_DIM ON T_BCM_STRUCTOFAUDITTRIAL ( FDIMENSIONID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_AT_PARENT') CREATE INDEX IDX_BCM_AT_PARENT ON T_BCM_STRUCTOFAUDITTRIAL ( FPARENTID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_ENT_DIM') CREATE INDEX IDX_BCM_ENT_DIM ON T_BCM_STRUCTOFENT ( FDIMENSIONID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_ENT_PARENT') CREATE INDEX IDX_BCM_ENT_PARENT ON T_BCM_STRUCTOFENT ( FPARENTID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_CT_DIM') CREATE INDEX IDX_BCM_CT_DIM ON T_BCM_STRUCTOFCHANGETYPE ( FDIMENSIONID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_CT_PARENT') CREATE INDEX IDX_BCM_CT_PARENT ON T_BCM_STRUCTOFCHANGETYPE ( FPARENTID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_SCENE_DIM') CREATE INDEX IDX_BCM_SCENE_DIM ON T_BCM_STRUCTOFSCENE ( FDIMENSIONID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_SCENE_PARENT') CREATE INDEX IDX_BCM_SCENE_PARENT ON T_BCM_STRUCTOFSCENE ( FPARENTID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_CURRENCY_DIM') CREATE INDEX IDX_BCM_CURRENCY_DIM ON T_BCM_STRUCTOFCURRENCY ( FDIMENSIONID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_CURRENCY_PARENT') CREATE INDEX IDX_BCM_CURRENCY_PARENT ON T_BCM_STRUCTOFCURRENCY ( FPARENTID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_ACCOUNT_DIM') CREATE INDEX IDX_BCM_ACCOUNT_DIM ON T_BCM_STRUCTOFACCOUNT ( FDIMENSIONID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_ACCOUNT_PARENT') CREATE INDEX IDX_BCM_ACCOUNT_PARENT ON T_BCM_STRUCTOFACCOUNT ( FPARENTID );

 EXEC P_ALTERPK 'PK_T_BCM_STRUCTOFMYCOMPANY', 'T_BCM_STRUCTOFMYCOMPANY', 'FID', '1';

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_STRUCTOFMYIC_LNUM') CREATE INDEX IDX_BCM_STRUCTOFMYIC_LNUM ON T_BCM_STRUCTOFMYCOMPANY ( FLONGNUMBER );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_STRUCTOFMYIC_DIM') CREATE INDEX IDX_BCM_STRUCTOFMYIC_DIM ON T_BCM_STRUCTOFMYCOMPANY ( FDIMENSIONID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_STRUCTMYIC_PARENT') CREATE INDEX IDX_BCM_STRUCTMYIC_PARENT ON T_BCM_STRUCTOFMYCOMPANY ( FPARENTID );


 EXEC P_ALTERPK 'PK_T_BCM_BIZRULESCENARIO', 'T_BCM_BIZRULESCENARIO', 'FPKID', '1';

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


 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_EB_PROJECT_DIM') CREATE INDEX IDX_BCM_EB_PROJECT_DIM ON T_BCM_STRUCTOFPROJECT ( FDIMENSIONID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_EB_PROJECT_PARENT') CREATE INDEX IDX_BCM_EB_PROJECT_PARENT ON T_BCM_STRUCTOFPROJECT ( FPARENTID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_UD_DIM') CREATE INDEX IDX_BCM_UD_DIM ON T_BCM_STRUCTOFDEFINED ( FDIMENSIONID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_UD_PARENT') CREATE INDEX IDX_BCM_UD_PARENT ON T_BCM_STRUCTOFDEFINED ( FPARENTID );

 EXEC P_ALTERPK 'PK_T_BCM_MERGEPROGRESS', 'T_BCM_MERGEPROGRESS', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_BCM_MERGEPROGRESS_SYPID') CREATE INDEX IDX_BCM_MERGEPROGRESS_SYPID ON T_BCM_MERGEPROGRESS ( FSCENARIOID ,FYEARID ,FPERIODID );



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