/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\MDS_constraint.sql **/
 EXEC P_ALTERPK 'PK_T_MDS_SAFESTK_ENTITY', 'T_MDS_SAFESTK_ENTITY', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_MDS_SAFESTK_ENTITY') CREATE INDEX IDX_MDS_SAFESTK_ENTITY ON T_MDS_SAFESTK_ENTITY ( FID ,FSEQ );


 EXEC P_ALTERPK 'PK_T_MDS_SAFETYSTOCK', 'T_MDS_SAFETYSTOCK', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_MDS_SAFETYSTOCK_M') CREATE INDEX IDX_MDS_SAFETYSTOCK_M ON T_MDS_SAFETYSTOCK ( FMATERIALID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_MDS_SAFETYSTOCK') CREATE INDEX IDX_MDS_SAFETYSTOCK ON T_MDS_SAFETYSTOCK ( FNUMBER ,FCREATEORGID );


 EXEC P_ALTERPK 'PK_T_MDS_SAFETYSTOCK_L', 'T_MDS_SAFETYSTOCK_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_MDS_SAFETYSTOCK_L') CREATE INDEX IDX_MDS_SAFETYSTOCK_L ON T_MDS_SAFETYSTOCK_L ( FID ,FLOCALEID );


 EXEC P_ALTERPK 'PK_T_MDS_XSBIZ', 'T_MDS_XSBIZ', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_MDS_XSBIZ') CREATE INDEX IDX_MDS_XSBIZ ON T_MDS_XSBIZ ( FID ,FBASEDATAID );


 EXEC P_ALTERPK 'PK_T_MDS_XSBT', 'T_MDS_XSBT', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_MDS_XSBT') CREATE INDEX IDX_MDS_XSBT ON T_MDS_XSBT ( FID ,FBASEDATAID );



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