/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\POM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_POM_MROTOOL') 
 CREATE TABLE T_POM_MROTOOL (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
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,
FBILLTYPE BIGINT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FPRODUCTNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMODEL NVARCHAR(50) DEFAULT ' ' NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBASEUNITID BIGINT DEFAULT 0 NOT NULL,
FBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTRANSACTIONTYPEID BIGINT DEFAULT 0 NOT NULL,
FAUXPROPERTY BIGINT DEFAULT 0 NOT NULL,
FORDERNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FORDERENTRYID BIGINT DEFAULT 0 NOT NULL,
FORDERSEQ NVARCHAR(50) DEFAULT ' ' NOT NULL,
FORDERSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCUSTOMER BIGINT DEFAULT 0 NOT NULL,
FWORKCARDID BIGINT DEFAULT 0 NOT NULL,
FCARDVERSION NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FREMARKS NVARCHAR(255) DEFAULT ' ' NOT NULL,
FORDERID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSOURCEBILLID BIGINT DEFAULT 0 NOT NULL,
FORDERIDNEW BIGINT DEFAULT 0 NOT NULL,
FORDERPLANSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FORDERTASKSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FORDERBIZSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FORDERPICKSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FWORKCENTER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPRODUCTMASTERID BIGINT DEFAULT 0 NOT NULL,
FMFTDEPTORGID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_POM_MROTOOLENTRY') 
 CREATE TABLE T_POM_MROTOOLENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FSTOCKSOURCE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMEANSTYPE BIGINT DEFAULT 0 NOT NULL,
FMATERIELMASTERID BIGINT DEFAULT 0 NOT NULL,
FMATERIALUNITID BIGINT DEFAULT 0 NOT NULL,
FDEMANDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBEGINTIME DATETIME,
FENDTIME DATETIME,
FENTRYLEVEL BIGINT DEFAULT 0 NOT NULL,
FFENTRYREPLACEGROUP NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSUPPLYMODE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUPPLIERID BIGINT DEFAULT 0 NOT NULL,
FSUPPLYORGID BIGINT DEFAULT 0 NOT NULL,
FWAREHOUSEID BIGINT DEFAULT 0 NOT NULL,
FLOCATION BIGINT DEFAULT 0 NOT NULL,
FMUSTSELECT CHAR(1) DEFAULT '0' NOT NULL,
FOUTQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FACTISSUEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FENTRYREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL,
FISBOMEXTEND CHAR(1) DEFAULT '0' NOT NULL,
FUSETIME DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MROORDERENTRY' AND KSQL_COL_NAME ='FDEFECTTYPEID') 
 ALTER TABLE T_POM_MROORDERENTRY ADD (FDEFECTTYPEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MROORDERENTRY' AND KSQL_COL_NAME ='FDEFECTDESC') 
 ALTER TABLE T_POM_MROORDERENTRY ADD (FDEFECTDESC NVARCHAR(500) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MROORDERENTRY' AND KSQL_COL_NAME ='FDISPOSALMEASURESID') 
 ALTER TABLE T_POM_MROORDERENTRY ADD (FDISPOSALMEASURESID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MROORDERENTRY' AND KSQL_COL_NAME ='FISMAJORDEFECT') 
 ALTER TABLE T_POM_MROORDERENTRY ADD (FISMAJORDEFECT CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MROORDERENTRY' AND KSQL_COL_NAME ='FDEFECTSITEID') 
 ALTER TABLE T_POM_MROORDERENTRY ADD (FDEFECTSITEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MROORDERENTRY' AND KSQL_COL_NAME ='FDEFECTREASONID') 
 ALTER TABLE T_POM_MROORDERENTRY ADD (FDEFECTREASONID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MROORDERENTRY' AND KSQL_COL_NAME ='FISRECHECK') 
 ALTER TABLE T_POM_MROORDERENTRY ADD (FISRECHECK CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MROORDERENTRY' AND KSQL_COL_NAME ='FISASSIST') 
 ALTER TABLE T_POM_MROORDERENTRY ADD (FISASSIST CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MROORDERENTRY' AND KSQL_COL_NAME ='FASSISTERID') 
 ALTER TABLE T_POM_MROORDERENTRY ADD (FASSISTERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MROORDERENTRY' AND KSQL_COL_NAME ='FISASSISTMANUAL') 
 ALTER TABLE T_POM_MROORDERENTRY ADD (FISASSISTMANUAL CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MROORDERENTRY' AND KSQL_COL_NAME ='FASSISTHOURS') 
 ALTER TABLE T_POM_MROORDERENTRY ADD (FASSISTHOURS DECIMAL(23,10) DEFAULT 0 NOT NULL );

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