/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\EB_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_REDUCE_OCCUPATION') 
 CREATE TABLE T_EB_REDUCE_OCCUPATION (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FBUSSINESSMODELID BIGINT DEFAULT 0 NOT NULL,
FMODIFIER BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FREDUCEADJUST CHAR(1) DEFAULT '0' NOT NULL,
FREDUCEREDISTRIBUTE CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_CURRENCYCONVERTSCHEM' AND KSQL_COL_NAME ='FNUMBER') 
 ALTER TABLE T_EB_CURRENCYCONVERTSCHEM ADD (FNUMBER NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_USERSELECT' AND KSQL_COL_NAME ='FBIZMODELID') 
 ALTER TABLE T_EB_USERSELECT ADD (FBIZMODELID BIGINT DEFAULT 0 NOT NULL );
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_DIFFANALYZESCHEME' AND KSQL_COL_NAME ='FCONFIGJSON') 
 ALTER TABLE T_EB_DIFFANALYZESCHEME ADD (FCONFIGJSON NCLOB);
 
 
 
-- 修复费用预算表状态为编制完成、已上报、已打回为编制中状态
IF EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_REPORT') 
UPDATE T_EB_REPORT SET FREPORTSTATUS = 'B' WHERE FREPORTSTATUS = 'C' OR FREPORTSTATUS = 'E' OR FREPORTSTATUS = 'D';




/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\EB_table.sql **/
