/**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_MROREPORTTASK') 
 CREATE TABLE T_POM_MROREPORTTASK (
FPKID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_POM_MROREPORTWBS') 
 CREATE TABLE T_POM_MROREPORTWBS (
FPKID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MFTORDERREPORT' AND KSQL_COL_NAME ='FSRCTYPE') 
 ALTER TABLE T_POM_MFTORDERREPORT ADD (FSRCTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MFTREPORTER' AND KSQL_COL_NAME ='FSTARTTIME') 
 ALTER TABLE T_POM_MFTREPORTER ADD (FSTARTTIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MFTREPORTER' AND KSQL_COL_NAME ='FCLOSETIME') 
 ALTER TABLE T_POM_MFTREPORTER ADD (FCLOSETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MFTREPORTER' AND KSQL_COL_NAME ='FREPWORKUNITID') 
 ALTER TABLE T_POM_MFTREPORTER ADD (FREPWORKUNITID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MFTREPORTER' AND KSQL_COL_NAME ='FACTCONSUMEDHOURS') 
 ALTER TABLE T_POM_MFTREPORTER ADD (FACTCONSUMEDHOURS DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MFTREPORTER' AND KSQL_COL_NAME ='FOPACTIVITY') 
 ALTER TABLE T_POM_MFTREPORTER ADD (FOPACTIVITY NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MFTREPORTACTIVITY' AND KSQL_COL_NAME ='FACTCHOURS') 
 ALTER TABLE T_POM_MFTREPORTACTIVITY ADD (FACTCHOURS DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MFTREPORTACTIVITY' AND KSQL_COL_NAME ='FACTIHOURS') 
 ALTER TABLE T_POM_MFTREPORTACTIVITY ADD (FACTIHOURS DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MFTREPORTACTIVITY' AND KSQL_COL_NAME ='FREPACTIVITYUNITID') 
 ALTER TABLE T_POM_MFTREPORTACTIVITY ADD (FREPACTIVITYUNITID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MFTREPORTSUMMARY' AND KSQL_COL_NAME ='FPROFESSIONID') 
 ALTER TABLE T_POM_MFTREPORTSUMMARY ADD (FPROFESSIONID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MFTREPORTSUMMARY' AND KSQL_COL_NAME ='FWORKUNITID') 
 ALTER TABLE T_POM_MFTREPORTSUMMARY ADD (FWORKUNITID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MFTREPORTSUMMARY' AND KSQL_COL_NAME ='FPLANCONSUMEDHOURS') 
 ALTER TABLE T_POM_MFTREPORTSUMMARY ADD (FPLANCONSUMEDHOURS DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MFTREPORTSUMMARY' AND KSQL_COL_NAME ='FTOTALINSPECTIONHOURS') 
 ALTER TABLE T_POM_MFTREPORTSUMMARY ADD (FTOTALINSPECTIONHOURS DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MFTREPORTSUMMARY' AND KSQL_COL_NAME ='FTOTALCONSUMEDHOURS') 
 ALTER TABLE T_POM_MFTREPORTSUMMARY ADD (FTOTALCONSUMEDHOURS DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MFTREPORTSUMMARY' AND KSQL_COL_NAME ='FHOURCONSUMPTIONRATE') 
 ALTER TABLE T_POM_MFTREPORTSUMMARY ADD (FHOURCONSUMPTIONRATE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MFTREPORTSUMMARY' AND KSQL_COL_NAME ='FSRCBILLENTITY') 
 ALTER TABLE T_POM_MFTREPORTSUMMARY ADD (FSRCBILLENTITY NVARCHAR(50) DEFAULT ' ' NOT NULL );

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