/**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_MROELECCONTROL') 
 CREATE TABLE T_POM_MROELECCONTROL (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO VARCHAR(50) DEFAULT ' ' NOT NULL,
FBILLSTATUS VARCHAR(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,
FORDERNO VARCHAR(50) DEFAULT ' ' NOT NULL,
FORDERENTRYID BIGINT DEFAULT 0 NOT NULL,
FMATERIAL BIGINT DEFAULT 0 NOT NULL,
FAUXPROPERTY BIGINT DEFAULT 0 NOT NULL,
FUNIT BIGINT DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBASEUNIT BIGINT DEFAULT 0 NOT NULL,
FBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTRANSACTIONTYPE BIGINT DEFAULT 0 NOT NULL,
FCUSTOMERID BIGINT DEFAULT 0 NOT NULL,
FBILLTYPE BIGINT DEFAULT 0 NOT NULL,
FWORKCARDID BIGINT DEFAULT 0 NOT NULL,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FFINEMODEL BIGINT DEFAULT 0 NOT NULL,
FAIRCRAFTREGISTNUM BIGINT DEFAULT 0 NOT NULL,
FORDERSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMAINTRADE BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_POM_MROELECENTRY') 
 CREATE TABLE T_POM_MROELECENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FMODIFIERFIELD BIGINT DEFAULT 0 NOT NULL,
FMODIFYDATEFIELD DATETIME,
FCBTOOLSTATUS VARCHAR(50) DEFAULT ' ' NOT NULL,
FPANEL NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCBLOCATION NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCBNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTAGCOUNTMOL BIGINT DEFAULT 0 NOT NULL,
FTAGCOUNTDEN BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_POM_MROELECSUBENTRY') 
 CREATE TABLE T_POM_MROELECSUBENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FWORKCARDNAME BIGINT DEFAULT 0 NOT NULL,
FPANEL NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCBLOCATION NVARCHAR(50) DEFAULT ' ' NOT NULL,
FORDERNO VARCHAR(50) DEFAULT ' ' NOT NULL,
FWORKDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPROFESSION BIGINT DEFAULT 0 NOT NULL,
FUSERFIELD BIGINT DEFAULT 0 NOT NULL,
FPHONENUM VARCHAR(50) DEFAULT ' ' NOT NULL,
FCARDNAME NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_POM_MROCODERULE_NOS') 
 CREATE TABLE T_POM_MROCODERULE_NOS (
FNUMBER VARCHAR(100) DEFAULT ' ' NOT NULL,
FPROJECTKEYS VARCHAR(80) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_POM_MROCODERULE_SEQ') 
 CREATE TABLE T_POM_MROCODERULE_SEQ (
FPROJECTKEYS VARCHAR(80) DEFAULT ' ' NOT NULL,
FCURRENTCHAR VARCHAR(20) DEFAULT ' ' NOT NULL,
FCURRENTSEQ BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_POM_TRANSTYPECODERULE') 
 CREATE TABLE T_POM_TRANSTYPECODERULE (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE VARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FISINTERRUPTNO CHAR(1) DEFAULT '0' NOT NULL,
FMROTRANSTYPEID BIGINT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MROORDER' AND KSQL_COL_NAME ='FNUMBERAUTOGEN') 
 ALTER TABLE T_POM_MROORDER ADD (FNUMBERAUTOGEN CHAR(1) DEFAULT '0' NOT NULL );

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