/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\ER_constraint.sql **/
 EXEC P_ALTERPK 'PK_T_ER_PUBREIMACCINFO', 'T_ER_PUBREIMACCINFO', 'FENTRYID', '1';

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


 EXEC P_ALTERPK 'PK_T_ER_PUBREIMBILL_L', 'T_ER_PUBREIMBILL_L', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_T_ER_PUBREIMEXPDET', 'T_ER_PUBREIMEXPDET', 'FDETAILID', '1';

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


 EXEC P_ALTERPK 'PK_T_ER_PUBREIMINVOICEINFO', 'T_ER_PUBREIMINVOICEINFO', 'FENTRYID', '1';

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


 EXEC P_ALTERPK 'PK_T_ER_PUBREIMINVOICEITEM', 'T_ER_PUBREIMINVOICEITEM', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_PUBREIM_IVCITE') CREATE INDEX IDX_ER_PUBREIM_IVCITE ON T_ER_PUBREIMINVOICEITEM ( FITEMENTRYID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_PUBREIM_IVCITE_INVHEAD') CREATE INDEX IDX_ER_PUBREIM_IVCITE_INVHEAD ON T_ER_PUBREIMINVOICEITEM ( FINVOICEHEADENTRYID );


 EXEC P_ALTERPK 'PK_T_ER_PUBREIMWRIOFFAPPLY', 'T_ER_PUBREIMWRIOFFAPPLY', 'FENTRYID', '1';

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


 EXEC P_ALTERPK 'PK_T_ER_PUBREIMWRIOFFDET', 'T_ER_PUBREIMWRIOFFDET', 'FENTRYID', '1';

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


 EXEC P_ALTERPK 'PK_T_ER_PUBREIMBILL', 'T_ER_PUBREIMBILL', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_PUBREIM_FBILLSTATUS') CREATE INDEX IDX_ER_PUBREIM_FBILLSTATUS ON T_ER_PUBREIMBILL ( FBILLSTATUS );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_PUBREIM_FAPPLIERID') CREATE INDEX IDX_ER_PUBREIM_FAPPLIERID ON T_ER_PUBREIMBILL ( FAPPLIERID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_PUBREIM_FCREATORID') CREATE INDEX IDX_ER_PUBREIM_FCREATORID ON T_ER_PUBREIMBILL ( FCREATORID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_PUBREIM_FCOMPANYID') CREATE INDEX IDX_ER_PUBREIM_FCOMPANYID ON T_ER_PUBREIMBILL ( FCOMPANYID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_PUBREIM_FBIZDATE_BNO') CREATE INDEX IDX_ER_PUBREIM_FBIZDATE_BNO ON T_ER_PUBREIMBILL ( FBIZDATE ,FBILLNO );



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