/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\POM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MFTORDERENTRY' AND KSQL_COL_NAME ='FSCHEDULER') 
 ALTER TABLE T_POM_MFTORDERENTRY ADD (FSCHEDULER BIGINT DEFAULT 0 NOT NULL);
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_XMFTORDERENTRY' AND KSQL_COL_NAME ='FSCHEDULER') 
 ALTER TABLE T_POM_XMFTORDERENTRY ADD (FSCHEDULER BIGINT DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MROORDERENTRY_E' AND KSQL_COL_NAME ='FJOBCONTENT') 
 ALTER TABLE T_POM_MROORDERENTRY_E ADD (FJOBCONTENT NVARCHAR(1000) DEFAULT ' ' NOT NULL);
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MROORDERENTRY_E' AND KSQL_COL_NAME ='FCONTRACTNO') 
 ALTER TABLE T_POM_MROORDERENTRY_E ADD (FCONTRACTNO NVARCHAR(50) DEFAULT ' ' NOT NULL);
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MROORDERENTRY_E' AND KSQL_COL_NAME ='FSUPPORTLOCATION') 
 ALTER TABLE T_POM_MROORDERENTRY_E ADD (FSUPPORTLOCATION NVARCHAR(255) DEFAULT ' ' NOT NULL);
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MROORDERENTRY_E' AND KSQL_COL_NAME ='FRELEASEREQ') 
 ALTER TABLE T_POM_MROORDERENTRY_E ADD (FRELEASEREQ NVARCHAR(255) DEFAULT ' ' NOT NULL);
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MROORDERENTRY_E' AND KSQL_COL_NAME ='FMAINSOURCEPLAN') 
 ALTER TABLE T_POM_MROORDERENTRY_E ADD (FMAINSOURCEPLAN NVARCHAR(50) DEFAULT ' ' NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_POM_MULFAVORER') 
 CREATE TABLE T_POM_MULFAVORER (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);
 EXEC P_ALTERPK 'PK_POM_MULFAVORER', 'T_POM_MULFAVORER', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_POM_MULFAVORER_FK') CREATE INDEX IDX_POM_MULFAVORER_FK ON T_POM_MULFAVORER ( FID );

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