/**Begin C:\PDM_UPGRADE\PDM1\SRM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_APTITUDE' AND KSQL_COL_NAME IN ('FISAUTOPUSH')) 
 ALTER TABLE T_PUR_APTITUDE ADD (FISAUTOPUSH CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRM_ACCESSNODE') 
 CREATE TABLE T_SRM_ACCESSNODE (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBIZOBJECT VARCHAR(36) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSTATUS CHAR(1) DEFAULT '1' NOT NULL,
FSERVICECLASS NVARCHAR(255) DEFAULT ' ' NOT NULL,
FMANDATORY CHAR(1) DEFAULT '0' NOT NULL,
FPRESET CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRM_ACCESSNODE_L') 
 CREATE TABLE T_SRM_ACCESSNODE_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRM_APTITUDE_NODEENTRY') 
 CREATE TABLE T_SRM_APTITUDE_NODEENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FACCESSNODEID BIGINT DEFAULT 0 NOT NULL,
FNODESTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FNODEBILLDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRM_APPROVEDETAIL') 
 CREATE TABLE T_SRM_APPROVEDETAIL (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FACCESSNODEID BIGINT DEFAULT 0 NOT NULL,
FNODEBILLNO VARCHAR(50) DEFAULT ' ' NOT NULL,
FNODESTATUS CHAR(1) DEFAULT ' ' NOT NULL
);



/**End C:\PDM_UPGRADE\PDM1\SRM_table.sql **/
