/**Begin D:\PDM_UPGRADE\PDM1\MSPLAN_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_DATESET' AND KSQL_COL_NAME ='FFORECAST_INPUTTYPE')
 ALTER TABLE T_MRP_DATESET ADD (FFORECAST_INPUTTYPE NVARCHAR(20) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_DATESET' AND KSQL_COL_NAME ='FSUMDIM')
 ALTER TABLE T_MRP_DATESET ADD (FSUMDIM NVARCHAR(20) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_DATESET' AND KSQL_COL_NAME ='FISAUTO_RELEASE')
 ALTER TABLE T_MRP_DATESET ADD (FISAUTO_RELEASE CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_DATESET' AND KSQL_COL_NAME ='FCREATORID')
 ALTER TABLE T_MRP_DATESET ADD (FCREATORID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_DATESET' AND KSQL_COL_NAME ='FMODIFIERID')
 ALTER TABLE T_MRP_DATESET ADD (FMODIFIERID BIGINT DEFAULT 0 NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_DATESET' AND KSQL_COL_NAME ='FSTATUS')
 ALTER TABLE T_MRP_DATESET ADD (FSTATUS NVARCHAR(20) DEFAULT ' ' NOT NULL );
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_DATESET' AND KSQL_COL_NAME ='FENABLE')
 ALTER TABLE T_MRP_DATESET ADD (FENABLE NVARCHAR(20) DEFAULT ' ' NOT NULL );
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_DATESET' AND KSQL_COL_NAME ='FMASTERID')
 ALTER TABLE T_MRP_DATESET ADD (FMASTERID BIGINT DEFAULT 0 NOT NULL );
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_DATESET' AND KSQL_COL_NAME ='FCREATEORGID')
 ALTER TABLE T_MRP_DATESET ADD (FCREATEORGID BIGINT DEFAULT 0 NOT NULL );
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_DATESET' AND KSQL_COL_NAME ='FNAME')
 ALTER TABLE T_MRP_DATESET ADD (FNAME NVARCHAR(200) DEFAULT ' ' NOT NULL );
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_DATESET' AND KSQL_COL_NAME ='FMRPPLANPROGRAM')
 ALTER TABLE T_MRP_DATESET ADD (FMRPPLANPROGRAM BIGINT DEFAULT 0 NOT NULL );
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_DATESET' AND KSQL_COL_NAME ='FMODIFYTIME')
 ALTER TABLE T_MRP_DATESET ADD (FMODIFYTIME DATETIME );
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_DATESET' AND KSQL_COL_NAME ='FCREATETIME')
 ALTER TABLE T_MRP_DATESET ADD (FCREATETIME DATETIME );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_DATESET_L')
 CREATE TABLE T_MRP_DATESET_L (
FPKID NVARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL
);

 EXEC P_ALTERPK 'PK_T_MRP_DATESET_L', 'T_MRP_DATESET_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_MRP_DATESET_L') CREATE INDEX IDX_MRP_DATESET_L ON T_MRP_DATESET_L ( FID ,FLOCALEID );

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