/** 相关lk表创建主键，建立索引，特别是T_ER_REIMBURSETRIPENTRY_LK 之前由领域自动创建了一个长度超过30的索引名，删除候再创建新的索引名  **/
 EXEC P_ALTERPK 'PK_T_ER_REQENTRY_LK', 'T_ER_REQENTRY_LK', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_REQENTRY_LK_FDETAILID') CREATE INDEX IDX_ER_REQENTRY_LK_FDETAILID ON T_ER_REQENTRY_LK ( FDETAILID );


 EXEC P_ALTERPK 'PK_T_ER_DAILYREIMBURSEBILL_LK', 'T_ER_DAILYREIMBURSEBILL_LK', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_T_ER_EXPENSEDETAIL_LK', 'T_ER_EXPENSEDETAIL_LK', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_EXPENSEDETAIL_LK_FDID') CREATE INDEX IDX_ER_EXPENSEDETAIL_LK_FDID ON T_ER_EXPENSEDETAIL_LK ( FDETAILID );


 EXEC P_ALTERPK 'PK_T_ER_REIMBURSETRIPENTRY_LK', 'T_ER_REIMBURSETRIPENTRY_LK', 'FPKID', '1';

 EXEC p_DropIdx 'IDX_ER_REIMBURSETRIPENTRY_LK_FK', 'T_ER_REIMBURSETRIPENTRY_LK';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_REIMBENTRY_LK_ENTRYID') CREATE INDEX IDX_ER_REIMBENTRY_LK_ENTRYID ON T_ER_REIMBURSETRIPENTRY_LK ( FENTRYID );



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