/**Begin D:\k3Cloud\PDM_UPGRADE\PDM1\MDS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_ALGORITHMDEF') 
 CREATE TABLE T_MDS_ALGORITHMDEF (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSRCBILL BIGINT DEFAULT 0 NOT NULL,
FDESTBILL BIGINT DEFAULT 0 NOT NULL,
FENABLE VARCHAR(5) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FISPRESET CHAR(1) DEFAULT '0' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_ALGORITHMDEST') 
 CREATE TABLE T_MDS_ALGORITHMDEST (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FCALDIMENSIONDEST NVARCHAR(255) DEFAULT ' ' NOT NULL,
FCALDIMENSIONVALDEST NVARCHAR(255) DEFAULT ' ' NOT NULL,
FFIELDIDDEST VARCHAR(50) DEFAULT ' ' NOT NULL,
FFIELDNAMEDEST VARCHAR(50) DEFAULT ' ' NOT NULL,
FCALCULATETEXTDEST NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FCALCULATEEXCDEST NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FCALCULATEEXCDEST_TAG NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FCALMETHODDEST VARCHAR(5) DEFAULT ' ' NOT NULL,
FDESCRIBEDEST NVARCHAR(500) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_ALGORITHMSRC') 
 CREATE TABLE T_MDS_ALGORITHMSRC (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FCALDIMENSIONSRC NVARCHAR(255) DEFAULT ' ' NOT NULL,
FCALDIMENSIONVALSRC NVARCHAR(255) DEFAULT ' ' NOT NULL,
FFIELDIDSRC VARCHAR(50) DEFAULT ' ' NOT NULL,
FFIELDNAMESRC VARCHAR(50) DEFAULT ' ' NOT NULL,
FCALCULATETEXTSRC NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FCALCULATEEXCSRC NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FCALCULATEEXCSRC_TAG NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FCALMETHODSRC VARCHAR(5) DEFAULT ' ' NOT NULL,
FDESCRIBESRC NVARCHAR(500) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_PROBABILITYDETAILS') 
 CREATE TABLE T_MDS_PROBABILITYDETAILS (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FENABLE VARCHAR(5) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FCUSTOMER BIGINT DEFAULT 0 NOT NULL,
FACTYPE BIGINT DEFAULT 0 NOT NULL,
FCHECKTYPE BIGINT DEFAULT 0 NOT NULL,
FPROJECT BIGINT DEFAULT 0 NOT NULL,
FCARDTYPE BIGINT DEFAULT 0 NOT NULL,
FCARD BIGINT DEFAULT 0 NOT NULL,
FMATERIALTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FMATERIAL DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT BIGINT DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUSEACCOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FACCOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUSEMONTHCOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAVGQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMAXQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMINQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLEVEL VARCHAR(50) DEFAULT ' ' NOT NULL,
FUSEPROBABILITY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUGGESTQTY DECIMAL(23,10) DEFAULT 0 NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_SAMPLERECORD') 
 CREATE TABLE T_MDS_SAMPLERECORD (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE VARCHAR(5) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FUSE CHAR(1) DEFAULT '0' NOT NULL,
FCUSTOMER BIGINT DEFAULT 0 NOT NULL,
FACTYPE BIGINT DEFAULT 0 NOT NULL,
FCHECKTYPE BIGINT DEFAULT 0 NOT NULL,
FACREG BIGINT DEFAULT 0 NOT NULL,
FPROJECT BIGINT DEFAULT 0 NOT NULL,
FCARDTYPE BIGINT DEFAULT 0 NOT NULL,
FCARD BIGINT DEFAULT 0 NOT NULL,
FMATERIALTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FMATERIAL DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT BIGINT DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUSEDATE DATETIME
);


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



/**End D:\k3Cloud\PDM_UPGRADE\PDM1\MDS_table.sql **/
