-- 平衡利库匹配明细表约束
EXEC P_ALTERPK 'PK_T_IM_BALINV_DETAILENTRY', 'T_IM_BALINV_DETAILENTRY', 'FENTRYID', '1';

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


EXEC P_ALTERPK 'PK_T_IM_BALINV_MATCHDETAIL', 'T_IM_BALINV_MATCHDETAIL', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_IM_BALINV_MATCHDETAIL' AND KSQL_INDNAME = 'IDX_BAL_MATCH_FNUMBER') CREATE INDEX IDX_BAL_MATCH_FNUMBER ON T_IM_BALINV_MATCHDETAIL ( FNUMBER );


EXEC P_ALTERPK 'PK_T_IM_BALINV_MATCHDETAIL_L', 'T_IM_BALINV_MATCHDETAIL_L', 'FPKID', '1';

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