/**Begin C:\PDM_UPGRADE\PDM1\PUR_constraint.sql **/
 EXEC P_ALTERPK 'PK_PUR_MODULECONSUBENTRY', 'T_PUR_MODULECONSUBENTRY', 'FDETAILID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_MOCONSENTRY_FSALOUTBID') CREATE INDEX IDX_PUR_MOCONSENTRY_FSALOUTBID ON T_PUR_MODULECONSUBENTRY ( FSALOUTID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_MOCONSENTRY_FDOWNBID') CREATE INDEX IDX_PUR_MOCONSENTRY_FDOWNBID ON T_PUR_MODULECONSUBENTRY ( FDOWNSTREAMBILLID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_MOCONSENTRY_FEID_FSEQ') CREATE INDEX IDX_PUR_MOCONSENTRY_FEID_FSEQ ON T_PUR_MODULECONSUBENTRY ( FENTRYID ,FSEQ );


 EXEC P_ALTERPK 'PK_PUR_MODULECONSUBENTRY_L', 'T_PUR_MODULECONSUBENTRY_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_MOCONSUBENTRY_L_FDID') CREATE UNIQUE INDEX IDX_PUR_MOCONSUBENTRY_L_FDID ON T_PUR_MODULECONSUBENTRY_L ( FDETAILID ,FLOCALEID );


 EXEC P_ALTERPK 'PK_PUR_MODULECONSUME', 'T_PUR_MODULECONSUME', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_MODULECONSUME_FBILLNO') CREATE INDEX IDX_PUR_MODULECONSUME_FBILLNO ON T_PUR_MODULECONSUME ( FBILLNO );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_MODULECON_FBILLDATE') CREATE INDEX IDX_PUR_MODULECON_FBILLDATE ON T_PUR_MODULECONSUME ( FBILLDATE );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_MODULECONSUME_FBIZID') CREATE INDEX IDX_PUR_MODULECONSUME_FBIZID ON T_PUR_MODULECONSUME ( FBIZPARTNERID );


 EXEC P_ALTERPK 'PK_T_PUR_MODULECONSUME_L', 'T_PUR_MODULECONSUME_L', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_PUR_MODULECONSUMEENTRY', 'T_PUR_MODULECONSUMEENTRY', 'FENTRYID', '1';

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


 EXEC P_ALTERPK 'PK_T_PUR_MODULEDELIVERY', 'T_PUR_MODULEDELIVERY', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_MODULEDELIVERY_FBILLNO') CREATE INDEX IDX_PUR_MODULEDELIVERY_FBILLNO ON T_PUR_MODULEDELIVERY ( FBILLNO );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_MODULEDEL_FBILLDATE') CREATE INDEX IDX_PUR_MODULEDEL_FBILLDATE ON T_PUR_MODULEDELIVERY ( FBILLDATE );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_MODULEDELIVERY_FBIZID') CREATE INDEX IDX_PUR_MODULEDELIVERY_FBIZID ON T_PUR_MODULEDELIVERY ( FBIZPARTNERID );


 EXEC P_ALTERPK 'PK_T_PUR_MODULEDELIVERY_L', 'T_PUR_MODULEDELIVERY_L', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_T_PUR_MODULEDELIVERYENTRY', 'T_PUR_MODULEDELIVERYENTRY', 'FENTRYID', '1';

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

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


 EXEC P_ALTERPK 'PK_T_PUR_MODULELIST', 'T_PUR_MODULELIST', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_MODULELIST_FBILLNO') CREATE INDEX IDX_PUR_MODULELIST_FBILLNO ON T_PUR_MODULELIST ( FBILLNO ,FCREATETIME );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_MODULELIST_FPOBILLNO') CREATE INDEX IDX_PUR_MODULELIST_FPOBILLNO ON T_PUR_MODULELIST ( FPOBILLNO ,FMFTORDERENTRYID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_MODULELIST_FBIZID') CREATE INDEX IDX_PUR_MODULELIST_FBIZID ON T_PUR_MODULELIST ( FBIZPARTNERID );


 EXEC P_ALTERPK 'PK_T_PUR_MODULELIST_L', 'T_PUR_MODULELIST_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_MODULELIST_L_FID') CREATE UNIQUE INDEX IDX_PUR_MODULELIST_L_FID ON T_PUR_MODULELIST_L ( FENTRYID ,FLOCALEID );


 EXEC P_ALTERPK 'PK_T_PUR_MODULELIST_SUB', 'T_PUR_MODULELIST_SUB', 'FDETAILID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_MODULELIST_SUB_FID') CREATE INDEX IDX_PUR_MODULELIST_SUB_FID ON T_PUR_MODULELIST_SUB ( FENTRYID ,FSEQ );


 EXEC P_ALTERPK 'PK_T_PUR_MODULELIST_SUB_L', 'T_PUR_MODULELIST_SUB_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_MODULELIST_SUB_L') CREATE UNIQUE INDEX IDX_PUR_MODULELIST_SUB_L ON T_PUR_MODULELIST_SUB_L ( FDETAILID ,FLOCALEID );


 EXEC P_ALTERPK 'PK_T_PUR_MODULERECEIPT', 'T_PUR_MODULERECEIPT', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_MODULERECEIPT_FBILLNO') CREATE INDEX IDX_PUR_MODULERECEIPT_FBILLNO ON T_PUR_MODULERECEIPT ( FBILLNO );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_MODULEREC_FBILLDATE') CREATE INDEX IDX_PUR_MODULEREC_FBILLDATE ON T_PUR_MODULERECEIPT ( FBILLDATE );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_MODULERECEIPT_FBIZID') CREATE INDEX IDX_PUR_MODULERECEIPT_FBIZID ON T_PUR_MODULERECEIPT ( FBIZPARTNERID );


 EXEC P_ALTERPK 'PK_T_PUR_MODULERECEIPT_L', 'T_PUR_MODULERECEIPT_L', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_PUR_MODULERECEIPTENTRY', 'T_PUR_MODULERECEIPTENTRY', 'FENTRYID', '1';

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

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


 EXEC P_ALTERPK 'PK_T_PUR_SALOUTSTOCKENTRY_S', 'T_PUR_SALOUTSTOCKENTRY_S', 'FDETAILID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_SALOUTSTOCKENTRY_S_FID') CREATE INDEX IDX_PUR_SALOUTSTOCKENTRY_S_FID ON T_PUR_SALOUTSTOCKENTRY_S ( FENTRYID ,FSEQ );


 EXEC P_ALTERPK 'PK_PUR_MODULERECEIPTREJATT', 'T_PUR_MODULERECEIPTREJATT', 'FPKID', '1';

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX__PUR_MORECREJATT_FBASEID') CREATE INDEX IDX__PUR_MORECREJATT_FBASEID ON T_PUR_MODULERECEIPTREJATT ( FBASEDATAID );


 EXEC P_ALTERPK 'PK_PUR_XORDERENTRY_S', 'T_PUR_XORDERENTRY_S', 'FDETAILID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_XORDERENTRY_S_FID') CREATE INDEX IDX_PUR_XORDERENTRY_S_FID ON T_PUR_XORDERENTRY_S ( FENTRYID ,FSEQ );


 EXEC P_ALTERPK 'PK_PUR_XORDERENTRY_S_L', 'T_PUR_XORDERENTRY_S_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_XORDERENTRY_S_L') CREATE UNIQUE INDEX IDX_PUR_XORDERENTRY_S_L ON T_PUR_XORDERENTRY_S_L ( FDETAILID ,FLOCALEID );

/**End C:\PDM_UPGRADE\PDM1\PUR_constraint.sql **/
