/**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_DENIFIEXCINFO') 
 CREATE TABLE T_MRP_DENIFIEXCINFO (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(60) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FGROUPID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FCTRLSTRATEGY NVARCHAR(30) DEFAULT ' ' NOT NULL,
FISREDLIGHT NVARCHAR(30) DEFAULT '0' NOT NULL,
FISYELLOWLIGHT NVARCHAR(30) DEFAULT '0' NOT NULL,
FISGREENLIGHT NVARCHAR(30) DEFAULT '0' NOT NULL,
FPRIORITY INT DEFAULT 0 NOT NULL,
FISVISIBLE NVARCHAR(30) DEFAULT '0' NOT NULL,
FISSHOW NVARCHAR(30) DEFAULT '0' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_EXCEPTIONGROUP') 
 CREATE TABLE T_MRP_EXCEPTIONGROUP (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(60) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE NVARCHAR(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 NVARCHAR(30) DEFAULT ' ' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_FIELDSETUP') 
 CREATE TABLE T_MRP_FIELDSETUP (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE NVARCHAR(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 NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBUSINESSENTITY NVARCHAR(36) DEFAULT ' ' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_FSENTRY') 
 CREATE TABLE T_MRP_FSENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSIGNID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSIGNNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDATATYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FVISABLE CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_PLANPROENTRY') 
 CREATE TABLE T_MRP_PLANPROENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FDEMANDSRC NVARCHAR(50) DEFAULT ' ' NOT NULL,
FISMRPOPERAT CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_PLANPROGRAM') 
 CREATE TABLE T_MRP_PLANPROGRAM (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE NVARCHAR(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 NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPLANOUTLOOK INT DEFAULT 0 NOT NULL,
FINVSUPPLYSTRATEGY BIGINT DEFAULT 0 NOT NULL,
FSUPPLYNET BIGINT DEFAULT 0 NOT NULL,
FISYIELD CHAR(1) DEFAULT '0' NOT NULL,
FISLOSSRATE CHAR(1) DEFAULT '0' NOT NULL,
FISMPS CHAR(1) DEFAULT '0' NOT NULL,
FISMRP CHAR(1) DEFAULT '0' NOT NULL,
FISREORDERPOINT CHAR(1) DEFAULT '0' NOT NULL,
FSAFESTOCKEFFECTSET NVARCHAR(30) DEFAULT ' ' NOT NULL,
FISADJUST CHAR(1) DEFAULT '0' NOT NULL,
FISREPLACE CHAR(1) DEFAULT '0' NOT NULL,
FISRESERVE CHAR(1) DEFAULT '0' NOT NULL,
FDEMANDMODEL BIGINT DEFAULT 0 NOT NULL,
FAPPMODE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCOMPUTEMODE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FOUTOFDATE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FDAY INT DEFAULT 0 NOT NULL,
FSUPPLYMODEL BIGINT DEFAULT 0 NOT NULL,
FSCOUTOFDATE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSCDAY INT DEFAULT 0 NOT NULL,
FADJUSTEFFECTSET NVARCHAR(30) DEFAULT ' ' NOT NULL,
FALLOWLEADTIME INT DEFAULT 0 NOT NULL,
FEARLYTOLER INT DEFAULT 0 NOT NULL,
FALLOWDELAYTIME INT DEFAULT 0 NOT NULL,
FDELAYTOLER INT DEFAULT 0 NOT NULL,
FCONSIDERBATCHSTR CHAR(1) DEFAULT '0' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_PLANPROREENTRY') 
 CREATE TABLE T_MRP_PLANPROREENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FENTITYTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FADJUSTSTRATEGY NVARCHAR(30) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_PLANPROSCENTRY') 
 CREATE TABLE T_MRP_PLANPROSCENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSUPPLYRES NVARCHAR(50) DEFAULT ' ' NOT NULL,
FISSCMRPOPERAT CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_PRIORITY') 
 CREATE TABLE T_MRP_PRIORITY (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE NVARCHAR(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 NVARCHAR(30) DEFAULT ' ' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_PRIORITYENTRY') 
 CREATE TABLE T_MRP_PRIORITYENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FELEMENTNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FELEMENTTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FOBJECTID NVARCHAR(36) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_RSREGISTER') 
 CREATE TABLE T_MRP_RSREGISTER (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FBUSINESSENTITY NVARCHAR(36) DEFAULT ' ' NOT NULL,
FTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FDATABASENTITY NVARCHAR(50) DEFAULT ' ' NOT NULL
);


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

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_BFTRANSFER') 
 CREATE TABLE T_MRP_BFTRANSFER (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FCTRLSTRATEGY NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSRCBILL NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSRCBILLENTITY NVARCHAR(30) DEFAULT ' ' NOT NULL,
FDESTBILL NVARCHAR(30) DEFAULT ' ' NOT NULL,
FDESTENTITY NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSTRATEGYCLASS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FISSYSTEMINSERT CHAR(1) DEFAULT '0' NOT NULL,
FLARGETEXTFIELD NVARCHAR(255) DEFAULT ' ' NOT NULL,
FLARGETEXTFIELD_TAG NCLOB,
FORGID BIGINT DEFAULT 0 NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_BILLTRANFERENTRY' AND KSQL_COL_NAME ='FCONVERTTYPE') 
 ALTER TABLE T_MRP_BILLTRANFERENTRY ADD (FCONVERTTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_BILLTRANFERENTRY' AND KSQL_COL_NAME ='FCALCULATETEXT') 
 ALTER TABLE T_MRP_BILLTRANFERENTRY ADD (FCALCULATETEXT NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_BILLTRANFERENTRY' AND KSQL_COL_NAME ='FCALCULATEEXC') 
 ALTER TABLE T_MRP_BILLTRANFERENTRY ADD (FCALCULATEEXC NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_BILLTRANFERENTRY' AND KSQL_COL_NAME ='FCALCULATEEXC_TAG') 
 ALTER TABLE T_MRP_BILLTRANFERENTRY ADD (FCALCULATEEXC_TAG NCLOB );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_BUSINESSPLANENTRY') 
 CREATE TABLE T_MRP_BUSINESSPLANENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FALGOMODEL BIGINT DEFAULT 0 NOT NULL
);

 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_PLANPRODMENTRY') 
 CREATE TABLE T_MRP_PLANPRODMENTRY (
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FELEMENTNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FELEMENTTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FDEMANDENTITY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDEMANDLOGO NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDEMANDNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FTYPENAME BIGINT DEFAULT 0 NOT NULL,
FFRUNCONDITION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FFRUNCONDITION_TAG NCLOB,
FFRUNCONDITIONDESC NVARCHAR(255) DEFAULT ' ' NOT NULL
);

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


 --- drop TABLE --------- 不允许删除表T_MRP_BILLFIELDTRANSFER，请恢复pdm ------------------- 
 --- drop TABLE --------- 不允许删除表T_MRP_BILLFIELDTRANSFER_L，请恢复pdm ------------------- 

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