/**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_MROSWSENTRY' AND KSQL_COL_NAME ='FFILECODEDETAIL') 
 ALTER TABLE T_POM_MROSWSENTRY ADD (FFILECODEDETAIL NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MROSWSENTRY' AND KSQL_COL_NAME ='FFILECODEDETAIL_TAG') 
 ALTER TABLE T_POM_MROSWSENTRY ADD (FFILECODEDETAIL_TAG NCLOB );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_POM_MROBATCHJOBLOG') 
 CREATE TABLE T_POM_MROBATCHJOBLOG (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(100) DEFAULT ' ' NOT NULL,
FPROJECT BIGINT DEFAULT 0 NOT NULL,
FTRANSACTIONTYPE BIGINT DEFAULT 0 NOT NULL,
FWORKSTAGE BIGINT DEFAULT 0 NOT NULL,
FCREATER BIGINT DEFAULT 0 NOT NULL,
FCREATEDATE DATETIME
);


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

 EXEC P_ALTERPK 'PK_POM_MROBATCHJOBLOG', 'T_POM_MROBATCHJOBLOG', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_POM_MROBATCHJOBLOG' AND KSQL_INDNAME = 'IDX_POM_MROBATCHJOBLOG_FBILLNO') CREATE INDEX IDX_POM_MROBATCHJOBLOG_FBILLNO ON T_POM_MROBATCHJOBLOG ( FBILLNO );


 EXEC P_ALTERPK 'PK_POM_MROBATCHJOBLOG_ENT', 'T_POM_MROBATCHJOBLOG_ENT', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_POM_MROBATCHJOBLOG_ENT' AND KSQL_INDNAME = 'IDX_POM_MROBATCHJOBLOG_ENT_FK') CREATE INDEX IDX_POM_MROBATCHJOBLOG_ENT_FK ON T_POM_MROBATCHJOBLOG_ENT ( FID );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_POM_MROBATCHJOBLOG' AND KSQL_COL_NAME ='FCARDBILLNO') 
 ALTER TABLE T_POM_MROBATCHJOBLOG ADD (FCARDBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL );
 
/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\POM_table.sql **/
