IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_ORDERPOOLDATA') 
 CREATE TABLE T_MDS_ORDERPOOLDATA (
	FID BIGINT DEFAULT 0 NOT NULL,
	FBILLNO VARCHAR(30) NOT NULL DEFAULT ' ' ,
	FBILLSTATUS VARCHAR(50) NOT NULL DEFAULT ' ' ,
	FCREATORID BIGINT DEFAULT 0 NOT NULL,
	FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
	FAUDITORID BIGINT DEFAULT 0 NOT NULL,
	FAUDITDATE DATETIME,
	FMODIFYTIME DATETIME,
	FCREATETIME DATETIME,
	FORGID BIGINT DEFAULT 0 NOT NULL,
	FSALORG BIGINT DEFAULT 0 NOT NULL,
	FOPERATORID BIGINT DEFAULT 0 NOT NULL,
	FCUSTOMERID BIGINT DEFAULT 0 NOT NULL,
	FSALBILLID BIGINT DEFAULT 0 NOT NULL,
	FSALBILLNO VARCHAR(30) NOT NULL DEFAULT ' ' ,
	FSALBILLSEQ VARCHAR(50) NOT NULL DEFAULT ' ' ,
	FSALBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
	FBILLTYPE BIGINT DEFAULT 0 NOT NULL,
	FSALBILLSTATUS VARCHAR(50) NOT NULL DEFAULT ' ' ,
	FMATERIAL BIGINT DEFAULT 0 NOT NULL,
	FCONFIGUREDCODE BIGINT DEFAULT 0 NOT NULL,
	FBASEUNIT BIGINT DEFAULT 0 NOT NULL,
	FREQQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
	FDELIVERYDATE DATETIME,
	FTRACKNUMBER BIGINT DEFAULT 0 NOT NULL,
	FCLOSESTATUS VARCHAR(50) NOT NULL DEFAULT ' ' ,
	FROWCLOSESTATUS VARCHAR(50) NOT NULL DEFAULT ' ' ,
	FPROORG BIGINT DEFAULT 0 NOT NULL,
	FSCHEDULEDPROQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
	FINVALIDSTATUS VARCHAR(50) NOT NULL DEFAULT ' ' ,
	FSALDEPTID BIGINT DEFAULT 0 NOT NULL,
	FUNSCHEDULEDPROQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
	FCHECKSTATUS VARCHAR(50) NOT NULL DEFAULT ' ' ,
	FRESOURCESSTATUS VARCHAR(50) NOT NULL DEFAULT ' ' ,
	FRESOURCESEXCEPTION VARCHAR(255) NOT NULL DEFAULT ' ' ,
	FRESOURCESEXCEPTION_TAG NCLOB DEFAULT ' ',
	FAPPROVEACCESS CHAR(1) DEFAULT '0' NOT NULL,
	FAPPROVEACCESSTIME DATETIME,
	FSALORDERLINEREMARK VARCHAR(50) NOT NULL DEFAULT ' ' ,
	FPLANPERSON BIGINT DEFAULT 0 NOT NULL,
	FAUXPTY BIGINT DEFAULT 0 NOT NULL,
	FISSPECIALPLAN CHAR(1) DEFAULT '0' NOT NULL,
	FEXPECTEDPRODELIVERYDATE DATETIME,
	FRETURNDETAIL VARCHAR(50) NOT NULL DEFAULT ' ' ,
	FRETURNMANS BIGINT DEFAULT 0 NOT NULL,
	FINVALIDREASON VARCHAR(255) NOT NULL DEFAULT ' ' ,
	FPROREPLYDELIVERYDATE DATETIME,
	FPROJECT BIGINT DEFAULT 0 NOT NULL,
	FRETURNDATE DATETIME,
	FSATISFACTION_DATE DATETIME,
	FSETDESIGNATION CHAR(1) DEFAULT '0' NOT NULL,
	FUNSCHEDULEDPRODATE DATETIME,
	FAPPROVEACCESSMANS BIGINT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_ORDERPOOLSETDATA') 
 CREATE TABLE T_MDS_ORDERPOOLSETDATA (
    FID BIGINT DEFAULT 0 NOT NULL,
    FNUMBER VARCHAR(30) NOT NULL DEFAULT ' ',
    FNAME VARCHAR(50) NOT NULL DEFAULT ' ',
    FSTATUS VARCHAR(50) NOT NULL DEFAULT ' ',
    FCREATORID BIGINT DEFAULT 0 NOT NULL,
    FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
    FENABLE VARCHAR(50) NOT NULL DEFAULT ' ',
    FCREATETIME DATETIME,
    FMODIFYTIME DATETIME,
    FMASTERID BIGINT DEFAULT 0 NOT NULL,
    FDAYSOFWEEK VARCHAR(50) NOT NULL DEFAULT ' ',
    FDAYSOFMON VARCHAR(50) NOT NULL DEFAULT ' ',
    FRUNNINGTYPE VARCHAR(50) NOT NULL DEFAULT ' ',
    FREPEATTYPE VARCHAR(50) NOT NULL DEFAULT ' ',
    FLOSEDATE DATETIME,
    FPREDTIME BIGINT DEFAULT 0 NOT NULL,
    FREPEAT CHAR(1) DEFAULT '0' NOT NULL,
    FJOBID VARCHAR(50) NOT NULL DEFAULT ' ',
    FPLANID VARCHAR(50) NOT NULL DEFAULT ' ',
    FDATACONF BIGINT DEFAULT 0 NOT NULL
);
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_ORDERPOOLSETDATA_L') 
 CREATE TABLE T_MDS_ORDERPOOLSETDATA_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_ORDERPOOLRES') 
CREATE TABLE T_MDS_ORDERPOOLRES (
	FID BIGINT DEFAULT 0 NOT NULL,
	FORDERPOOLID BIGINT DEFAULT 0 NOT NULL,
	FSALBILLNO VARCHAR(50) NOT NULL DEFAULT ' ',
	FMATERIAL  BIGINT DEFAULT 0 NOT NULL,
	FCONFIGUREDCODE  BIGINT DEFAULT 0 NOT NULL,
	FREQQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
	FBASEUNIT  BIGINT DEFAULT 0 NOT NULL,
	FBILLTYPE  BIGINT DEFAULT 0 NOT NULL,
	FDELIVERYDATE DATETIME
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_ORDERPOOLRESENTRY') 
CREATE TABLE T_MDS_ORDERPOOLRESENTRY (
        FID BIGINT DEFAULT 0 NOT NULL,
        FENTRYID BIGINT DEFAULT 0 NOT NULL,
        FSEQ BIGINT DEFAULT 0 NOT NULL,
        FERRORINFO VARCHAR(255) NOT NULL DEFAULT ' '
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_ORDERPOOLBILLENTRY') 
CREATE TABLE T_MDS_ORDERPOOLBILLENTRY (
	FID BIGINT DEFAULT 0 NOT NULL,
	FENTRYID BIGINT DEFAULT 0 NOT NULL,
	FSEQ BIGINT NOT NULL DEFAULT 0,
	FMODIFIERFIELD BIGINT DEFAULT 0 NOT NULL,
	FMODIFYDATEFIELD DATETIME,
	FENTRYSHEDULEDATE DATETIME,
	FENTRYSCHEDULEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
	FENTRYMANUFACTURENUM VARCHAR(50) NOT NULL DEFAULT ' ',
	FENTRYMANUFACTURESEQ BIGINT DEFAULT 0 NOT NULL,
	FENTRYENDWORKDATE DATETIME,
	FENTRYONDATE DATETIME,
	FENTRYSCHEDULEPLANNO VARCHAR(255) NOT NULL DEFAULT ' ',
	FENTRYSCHEDULEPLANID BIGINT DEFAULT 0 NOT NULL,
	FENTRYMANUFACTUREID BIGINT DEFAULT 0 NOT NULL,
	FENTRYMANUFACTUREENTRYID BIGINT DEFAULT 0 NOT NULL,
	FENTRYMANUFACTUREQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
	FENTRYPLANSTARTWORKTIME DATETIME,
	FENTRYPLANENDWORKTIME DATETIME,
	FENTRYLINSTOCKQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
	FENTRTYCREATOR BIGINT DEFAULT 0 NOT NULL,
	FENTRYCREATEDATE DATETIME
);