/**Begin D:\PDM_UPGRADE\PDM1\MRP_table.sql **/
-- 模拟协同计划单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_SIMCOLORDER' AND KSQL_COL_NAME ='FINTER_COLLABORTYPE')
 ALTER TABLE T_MRP_SIMCOLORDER ADD (FINTER_COLLABORTYPE BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_SIMCOLORDER' AND KSQL_COL_NAME ='FINWARELOCATION')
 ALTER TABLE T_MRP_SIMCOLORDER ADD (FINWARELOCATION BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_SIMCOLORDER' AND KSQL_COL_NAME ='FINWAREHOUSE')
 ALTER TABLE T_MRP_SIMCOLORDER ADD (FINWAREHOUSE BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_SIMCOLORDER' AND KSQL_COL_NAME ='FINWARORG')
 ALTER TABLE T_MRP_SIMCOLORDER ADD (FINWARORG BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_SIMCOLORDER' AND KSQL_COL_NAME ='FPLANSCOPE')
 ALTER TABLE T_MRP_SIMCOLORDER ADD (FPLANSCOPE BIGINT DEFAULT 0 NOT NULL );
  -- 模拟协同计划单新增需求单据实体字段
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_SIMCOLORDER' AND KSQL_COL_NAME ='FDEMANDBILLENTITY')
 ALTER TABLE T_MRP_SIMCOLORDER ADD (FDEMANDBILLENTITY NVARCHAR(50) DEFAULT ' ' NOT NULL );

  -- 模拟协同计划单新增需求单据ID字段
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_SIMCOLORDER' AND KSQL_COL_NAME ='FDEMANDBILLID')
 ALTER TABLE T_MRP_SIMCOLORDER ADD (FDEMANDBILLID NVARCHAR(50) DEFAULT ' ' NOT NULL );

 -- 模拟协同计划单新增需求单据编号字段
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_SIMCOLORDER' AND KSQL_COL_NAME ='FDEMANDBILL')
 ALTER TABLE T_MRP_SIMCOLORDER ADD (FDEMANDBILL NVARCHAR(50) DEFAULT ' ' NOT NULL );

 -- 模拟协同计划单新增需求单据行号字段
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_SIMCOLORDER' AND KSQL_COL_NAME ='FDEMANDSEQ')
 ALTER TABLE T_MRP_SIMCOLORDER ADD (FDEMANDSEQ INT DEFAULT 0 NOT NULL );

 -- 模拟协同计划单新增需求单据分录ID字段
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_SIMCOLORDER' AND KSQL_COL_NAME ='FDEMANDBILLENTRYID')
 ALTER TABLE T_MRP_SIMCOLORDER ADD (FDEMANDBILLENTRYID NVARCHAR(50) DEFAULT ' ' NOT NULL );

 
 -- 协同计划单新增需求单据实体字段
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_RATIVEORDER' AND KSQL_COL_NAME ='FDEMANDBILLENTITY') 
 ALTER TABLE T_MRP_RATIVEORDER ADD (FDEMANDBILLENTITY NVARCHAR(50) DEFAULT ' ' NOT NULL );

  -- 协同计划单新增需求单据ID字段
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_RATIVEORDER' AND KSQL_COL_NAME ='FDEMANDBILLID') 
 ALTER TABLE T_MRP_RATIVEORDER ADD (FDEMANDBILLID NVARCHAR(50) DEFAULT ' ' NOT NULL );
 
 -- 协同计划单新增需求单据编号字段
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_RATIVEORDER' AND KSQL_COL_NAME ='FDEMANDBILL') 
 ALTER TABLE T_MRP_RATIVEORDER ADD (FDEMANDBILL NVARCHAR(50) DEFAULT ' ' NOT NULL );
 
 -- 协同计划单新增需求单据行号字段
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_RATIVEORDER' AND KSQL_COL_NAME ='FDEMANDSEQ') 
 ALTER TABLE T_MRP_RATIVEORDER ADD (FDEMANDSEQ INT DEFAULT 0 NOT NULL );
 
 -- 协同计划单新增需求单据分录ID字段
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_RATIVEORDER' AND KSQL_COL_NAME ='FDEMANDBILLENTRYID') 
 ALTER TABLE T_MRP_RATIVEORDER ADD (FDEMANDBILLENTRYID NVARCHAR(50) DEFAULT ' ' NOT NULL );

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