/* 费用预提单 主表 start */
EXEC P_ALTERPK 'PK_ER_WITHHOLDINGBILL', 'T_ER_WITHHOLDINGBILL', 'FID', '1';

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

IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_WH_BILLSTATUS') CREATE INDEX IDX_ER_WH_BILLSTATUS ON T_ER_WITHHOLDINGBILL ( FBILLSTATUS );
/* 费用预提单 主表 end */


/* 费用预提单 主表 多语言 start */
EXEC P_ALTERPK 'PK_ER_WITHHOLDINGBILL_L', 'T_ER_WITHHOLDINGBILL_L', 'FPKID', '1';

IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_WH_L_ID') CREATE INDEX IDX_ER_WH_L_ID ON T_ER_WITHHOLDINGBILL_L ( FID ,FLOCALEID );
/* 费用预提单 主表 多语言 end */


/* 费用预提单 关联表 start */
EXEC P_ALTERPK 'PK_ER_WITHHOLDINGBILL_LK', 'T_ER_WITHHOLDINGBILL_LK', 'FPKID', '1';

IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_WH_LK_ID') CREATE INDEX IDX_ER_WH_LK_ID ON T_ER_WITHHOLDINGBILL_LK ( FID ,FSEQ );
/* 费用预提单 关联表 end */

/* 费用预提单 追踪表 start */
EXEC P_ALTERPK 'PK_ER_WITHHOLDINGBILL_TC', 'T_ER_WITHHOLDINGBILL_TC', 'FID', '1';

IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_WH_TC_ID') CREATE INDEX IDX_ER_WH_TC_ID ON T_ER_WITHHOLDINGBILL_TC ( FTBILLID );
/* 费用预提单 追踪表 end */

/* 费用预提单 反写记录表 start */
EXEC P_ALTERPK 'PK_ER_WITHHOLDINGBILL_WB', 'T_ER_WITHHOLDINGBILL_WB', 'FENTRYID', '1';

IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_WH_WB_ID') CREATE INDEX IDX_ER_WH_WB_ID ON T_ER_WITHHOLDINGBILL_WB ( FID ,FSEQ );
/* 费用预提单 反写记录表 end */

/* 费用预提单 明细 start */
EXEC P_ALTERPK 'PK_ER_WITHHOLDINGENTRY', 'T_ER_WITHHOLDINGENTRY', 'FENTRYID', '1';

IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_WH_EN_COMID') CREATE INDEX IDX_ER_WH_EN_COMID ON T_ER_WITHHOLDINGENTRY ( FENTRYCOSTCOMPANYID );

IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_WH_EN_DEPTID') CREATE INDEX IDX_ER_WH_EN_DEPTID ON T_ER_WITHHOLDINGENTRY ( FENTRYCOSTDEPTID );
/* 费用预提单 明细 end */

/* 费用预提单 明细 关联表 start */
EXEC P_ALTERPK 'PK_ER_WITHHOLDINGENTRY_LK', 'T_ER_WITHHOLDINGENTRY_LK', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_WH_EN_L_ID') CREATE INDEX IDX_ER_WH_EN_L_ID ON T_ER_WITHHOLDINGENTRY_LK ( FSEQ ,FENTRYID ,FSBILLID );
/* 费用预提单 明细 关联表 end */