/**Begin D:\PDM_UPGRADE\PDM1\EB_table.sql **/
/** 分摊公式上增加体系字段 */
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_SHARESCHEME_ENTITY' AND KSQL_COL_NAME ='FMODELID') 
ALTER TABLE T_EB_SHARESCHEME_ENTITY ADD (FMODELID BIGINT DEFAULT 0 NOT NULL );

/** 更新分摊公式上体系的数据 */
IF EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_SHARESCHEME_ENTITY' AND KSQL_COL_NAME ='FMODELID')
UPDATE T_EB_SHARESCHEME_ENTITY SET FMODELID = (SELECT T.FMODEL FROM T_EB_SHARESCHEME_GROUP T WHERE T.FID = T_EB_SHARESCHEME_ENTITY.FSCHEMEGROUP) WHERE FSCHEMEGROUP IN (SELECT FID FROM T_EB_SHARESCHEME_GROUP);


/**End D:\PDM_UPGRADE\PDM1\EB_table.sql **/
