/** 18周临时脚本 */
/** 预算任务上增加体系字段 */
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_TASK' AND KSQL_COL_NAME ='FMODELID') 
ALTER TABLE T_EB_TASK ADD (FMODELID BIGINT DEFAULT 0 NOT NULL );


/** 更新预算任务上体系的数据 */
IF EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_TASK' AND KSQL_COL_NAME ='FMODELID')
update t_eb_task set fmodelid = (select t.fmodelid from t_eb_tasklist t where t.fid = t_eb_task.ftasklistid) where ftasklistid in (select fid from t_eb_tasklist);


/** 勾稽关系上增加体系字段 */
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_EXAMINE' AND KSQL_COL_NAME ='FMODELID') 
ALTER TABLE T_EB_EXAMINE ADD (FMODELID BIGINT DEFAULT 0 NOT NULL );


/** 更新勾稽关系上体系的数据 */
IF EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_EXAMINE' AND KSQL_COL_NAME ='FMODELID')
update t_eb_examine set fmodelid = (select t.fmodelid from t_eb_examinecategory t where t.fid = t_eb_examine.fgroup) where fgroup in (select fid from t_eb_examinecategory);