/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\MRP_table.sql **/

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_PLANCALENDAR_L') 
 CREATE TABLE T_MRP_PLANCALENDAR_L (
FPKID VARCHAR(18) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME VARCHAR(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_PLANCALENDAR') 
 CREATE TABLE T_MRP_PLANCALENDAR (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(60) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE VARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FCTRLSTRATEGY VARCHAR(30) DEFAULT ' ' NOT NULL,
FISSUNREST CHAR(1) DEFAULT '1' NOT NULL,
FISMONREST CHAR(1) DEFAULT '0' NOT NULL,
FISTUEREST CHAR(1) DEFAULT '0' NOT NULL,
FISWEDREST CHAR(1) DEFAULT '0' NOT NULL,
FISTHUREST CHAR(1) DEFAULT '0' NOT NULL,
FISFRIREST CHAR(1) DEFAULT '0' NOT NULL,
FISSATREST CHAR(1) DEFAULT '1' NOT NULL,
FISHALFSUNREST CHAR(1) DEFAULT '0' NOT NULL,
FISHALFMONREST CHAR(1) DEFAULT '0' NOT NULL,
FISHALFTUEREST CHAR(1) DEFAULT '0' NOT NULL,
FISHALFWEDREST CHAR(1) DEFAULT '0' NOT NULL,
FISHALFTHUREST CHAR(1) DEFAULT '0' NOT NULL,
FISHALFFRIREST CHAR(1) DEFAULT '0' NOT NULL,
FISHALFSATREST CHAR(1) DEFAULT '0' NOT NULL,
FEXPIRINGYEARFROM VARCHAR(30) DEFAULT ' ' NOT NULL,
FEXPIRINGMONTHFROM VARCHAR(30) DEFAULT ' ' NOT NULL,
FEXPIRINGYEARTO VARCHAR(30) DEFAULT ' ' NOT NULL,
FEXPIRINGMONTHTO VARCHAR(30) DEFAULT ' ' NOT NULL,
FISDEFALT CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_PLANCALENDARENTRY') 
 CREATE TABLE T_MRP_PLANCALENDARENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FWORKDATE DATETIME,
FDATETYPE VARCHAR(30) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_PLANCALENDAR' AND KSQL_COL_NAME ='FMPDMCALENDARID') 
 ALTER TABLE T_MRP_PLANCALENDAR ADD (FMPDMCALENDARID BIGINT DEFAULT 0 NOT NULL );

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