/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\TCTB_constraint.sql **/
 EXEC P_ALTERPK 'PK_TCTB_XORGMAPBUSOBJECT', 'T_TCTB_XORGMAPBUSOBJECT', 'FDETAILID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_TCTB_XORGMAPBUSOBJECT' AND KSQL_INDNAME = 'IDX_TCTB_XORGMAPBUS_FK') CREATE INDEX IDX_TCTB_XORGMAPBUS_FK ON T_TCTB_XORGMAPBUSOBJECT ( FENTRYID );


 EXEC P_ALTERPK 'PK_TCTB_XORGMAPRELATION', 'T_TCTB_XORGMAPRELATION', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_TCTB_XORGMAPRELATION' AND KSQL_INDNAME = 'IDX_TCTB_XORGMR_SOURCEID') CREATE INDEX IDX_TCTB_XORGMR_SOURCEID ON T_TCTB_XORGMAPRELATION ( FSOURCEBILLID );


 EXEC P_ALTERPK 'PK_TCTB_XORGMAPRELATION_L', 'T_TCTB_XORGMAPRELATION_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_TCTB_XORGMAPRELATION_L' AND KSQL_INDNAME = 'IDX_TCTB_XORGMAPRELATION_L_0') CREATE INDEX IDX_TCTB_XORGMAPRELATION_L_0 ON T_TCTB_XORGMAPRELATION_L ( FENTRYID ,FLOCALEID );


 EXEC P_ALTERPK 'PK_TCTB_XORG_GROUP', 'T_TCTB_XORG_GROUP', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_TCTB_XORG_GROUP' AND KSQL_INDNAME = 'IDX_TCTB_XORGG_SOURID') CREATE INDEX IDX_TCTB_XORGG_SOURID ON T_TCTB_XORG_GROUP ( FSOURCEBILLID );


 EXEC P_ALTERPK 'PK_TCTB_XORG_GROUP_L', 'T_TCTB_XORG_GROUP_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_TCTB_XORG_GROUP_L' AND KSQL_INDNAME = 'IDX_TCTB_XORG_GROUP_L_0') CREATE INDEX IDX_TCTB_XORG_GROUP_L_0 ON T_TCTB_XORG_GROUP_L ( FID ,FLOCALEID );


 EXEC P_ALTERPK 'PK_TCTB_XORGGROUP_DETAIL', 'T_TCTB_XORGGROUP_DETAIL', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_TCTB_XORGGROUP_DETAIL' AND KSQL_INDNAME = 'IDX_TCTB_XORGG_DETAIL_FK') CREATE INDEX IDX_TCTB_XORGG_DETAIL_FK ON T_TCTB_XORGGROUP_DETAIL ( FID );


 EXEC P_ALTERPK 'PK_TCTB_XORGGROUP_PARAM', 'T_TCTB_XORGGROUP_PARAM', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_TCTB_XORGGROUP_PARAM' AND KSQL_INDNAME = 'IDX_TCTB_XORGG_PARAM_FK') CREATE INDEX IDX_TCTB_XORGG_PARAM_FK ON T_TCTB_XORGGROUP_PARAM ( FID );



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