-- 费用报销单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYREIMBURSEBILL_A' AND KSQL_COL_NAME IN ('FATTACHMENTCOUNT'))
ALTER TABLE T_ER_DAILYREIMBURSEBILL_A ADD (FATTACHMENTCOUNT INT DEFAULT 0 NOT NULL);

-- 对公报销单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PUBREIMBILL' AND KSQL_COL_NAME IN ('FATTACHMENTCOUNT'))
ALTER TABLE T_ER_PUBREIMBILL ADD (FATTACHMENTCOUNT INT DEFAULT 0 NOT NULL);

-- 费用申请单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYAPPLYBILL' AND KSQL_COL_NAME IN ('FATTACHMENTCOUNT'))
ALTER TABLE T_ER_DAILYAPPLYBILL ADD (FATTACHMENTCOUNT INT DEFAULT 0 NOT NULL);

-- 借款单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYLOANBILL' AND KSQL_COL_NAME IN ('FATTACHMENTCOUNT'))
ALTER TABLE T_ER_DAILYLOANBILL ADD (FATTACHMENTCOUNT INT DEFAULT 0 NOT NULL);

-- 额度申请单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_REIMCTLAPPLYBILL' AND KSQL_COL_NAME IN ('FATTACHMENTCOUNT'))
ALTER TABLE T_ER_REIMCTLAPPLYBILL ADD (FATTACHMENTCOUNT INT DEFAULT 0 NOT NULL);

-- 日常用车申请单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_DAILYVEHICLEBILL' AND KSQL_COL_NAME IN ('FATTACHMENTCOUNT'))
ALTER TABLE T_ER_DAILYVEHICLEBILL ADD (FATTACHMENTCOUNT INT DEFAULT 0 NOT NULL);

-- 差旅报销单、差旅报销单（表）
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_REIMBURSEBILL' AND KSQL_COL_NAME IN ('FATTACHMENTCOUNT'))
ALTER TABLE T_ER_REIMBURSEBILL ADD (FATTACHMENTCOUNT INT DEFAULT 0 NOT NULL);

-- 出差申请单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_REQBILL_A' AND KSQL_COL_NAME IN ('FATTACHMENTCOUNT'))
ALTER TABLE T_ER_REQBILL_A ADD (FATTACHMENTCOUNT INT DEFAULT 0 NOT NULL);

-- 立项单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_APPLYPROJECTBILL_S' AND KSQL_COL_NAME IN ('FATTACHMENTCOUNT'))
ALTER TABLE T_ER_APPLYPROJECTBILL_S ADD (FATTACHMENTCOUNT INT DEFAULT 0 NOT NULL);

-- 暂估单、资产暂估单（布局）
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_COSTESTIMATEBILL' AND KSQL_COL_NAME IN ('FATTACHMENTCOUNT'))
ALTER TABLE T_ER_COSTESTIMATEBILL ADD (FATTACHMENTCOUNT INT DEFAULT 0 NOT NULL);

-- 费用预提单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_WITHHOLDINGBILL' AND KSQL_COL_NAME IN ('FATTACHMENTCOUNT'))
ALTER TABLE T_ER_WITHHOLDINGBILL ADD (FATTACHMENTCOUNT INT DEFAULT 0 NOT NULL);

-- 合同台账单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_CONTRACTBILL_S' AND KSQL_COL_NAME IN ('FATTACHMENTCOUNT'))
ALTER TABLE T_ER_CONTRACTBILL_S ADD (FATTACHMENTCOUNT INT DEFAULT 0 NOT NULL);

-- 需求补充单据
-- 付款申请单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_APPLYPAYBILL' AND KSQL_COL_NAME IN ('FATTACHMENTCOUNT'))
ALTER TABLE T_ER_APPLYPAYBILL ADD (FATTACHMENTCOUNT INT DEFAULT 0 NOT NULL);
-- 预付单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_PREPAYBILL' AND KSQL_COL_NAME IN ('FATTACHMENTCOUNT'))
ALTER TABLE T_ER_PREPAYBILL ADD (FATTACHMENTCOUNT INT DEFAULT 0 NOT NULL);
-- 还款单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_REPAYMENTBILL' AND KSQL_COL_NAME IN ('FATTACHMENTCOUNT'))
ALTER TABLE T_ER_REPAYMENTBILL ADD (FATTACHMENTCOUNT INT DEFAULT 0 NOT NULL);
-- 费用分摊单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_EXPENSESHAREBILL' AND KSQL_COL_NAME IN ('FATTACHMENTCOUNT'))
ALTER TABLE T_ER_EXPENSESHAREBILL ADD (FATTACHMENTCOUNT INT DEFAULT 0 NOT NULL);

-- 借款报表
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_LOANBILLDS' AND KSQL_COL_NAME IN ('FATTACHMENTCOUNT'))
ALTER TABLE T_ER_LOANBILLDS ADD (FATTACHMENTCOUNT INT DEFAULT 0 NOT NULL);
-- 费用明细查询表
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_REIMBURSEBILLDS_A' AND KSQL_COL_NAME IN ('FATTACHMENTCOUNT'))
ALTER TABLE T_ER_REIMBURSEBILLDS_A ADD (FATTACHMENTCOUNT INT DEFAULT 0 NOT NULL);