/**Begin D:\PDM_UPGRADE\PDM1\HRCS_table.sql **/

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_ROLEDIMENSION' AND KSQL_COL_NAME IN ('FBUCAFUNCID')) 
 ALTER TABLE T_HRCS_ROLEDIMENSION ADD (FBUCAFUNCID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_DIMENSION' AND KSQL_COL_NAME IN ('FDATASOURCE')) 
 ALTER TABLE T_HRCS_DIMENSION ADD (FDATASOURCE VARCHAR(20) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_ENTITYDIMENTRY_L') 
 CREATE TABLE T_HRCS_ENTITYDIMENTRY_L (
FPKID VARCHAR(18) DEFAULT ' ' NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_ENTITYCTRL') 
 CREATE TABLE T_HRCS_ENTITYCTRL (
FID BIGINT DEFAULT 0 NOT NULL,
FAPPID VARCHAR(36) DEFAULT ' ' NOT NULL,
FENTITYTYPEID VARCHAR(36) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_ENTITYDIMENTRY') 
 CREATE TABLE T_HRCS_ENTITYDIMENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FDIMENSIONID BIGINT DEFAULT 0 NOT NULL,
FPROPKEY VARCHAR(60) DEFAULT ' ' NOT NULL,
FISSYSPRESET CHAR(1) DEFAULT ' ' NOT NULL,
FISMUST CHAR(1) DEFAULT ' ' NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_ENTITYTREECFG') 
 CREATE TABLE T_HRCS_ENTITYTREECFG (
FID BIGINT DEFAULT 0 NOT NULL,
FAPPID VARCHAR(36) DEFAULT ' ' NOT NULL,
FENTITYTYPEID VARCHAR(36) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FINDEX BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_PERMRELAT') 
 CREATE TABLE T_HRCS_PERMRELAT (
FID BIGINT DEFAULT 0 NOT NULL,
FAPPID VARCHAR(36) DEFAULT ' ' NOT NULL,
FENTITYTYPEID VARCHAR(36) DEFAULT ' ' NOT NULL,
FPERMITEMID VARCHAR(18) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_PERMRELATENTRY') 
 CREATE TABLE T_HRCS_PERMRELATENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FAPPID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FENTITYTYPEID VARCHAR(36) DEFAULT ' ' NOT NULL,
FPERMITEMID VARCHAR(1000) DEFAULT ' ' NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_ENTITYFORBID') 
 CREATE TABLE T_HRCS_ENTITYFORBID (
FID BIGINT DEFAULT 0 NOT NULL,
FENTITYTYPEID VARCHAR(36) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_ROLEDIMGRP') 
 CREATE TABLE T_HRCS_ROLEDIMGRP (
FID BIGINT DEFAULT 0 NOT NULL,
FROLEID VARCHAR(18) DEFAULT ' ' NOT NULL,
FBUCAFUNCID BIGINT DEFAULT 0 NOT NULL,
FINDEX INT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_ROLEDIMVAL') 
 CREATE TABLE T_HRCS_ROLEDIMVAL (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FDIMENSIONID BIGINT DEFAULT 0 NOT NULL,
FISALL CHAR(1) DEFAULT ' ' NOT NULL,
FDIMVAL VARCHAR(500) DEFAULT ' ' NOT NULL,
FCONTAINSSUB CHAR(1) DEFAULT ' ' NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_USERROLEDIMGRP') 
 CREATE TABLE T_HRCS_USERROLEDIMGRP (
FID BIGINT DEFAULT 0 NOT NULL,
FUSERROLERELATID BIGINT DEFAULT 0 NOT NULL,
FBUCAFUNCID BIGINT DEFAULT 0 NOT NULL,
FINDEX INT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_USERROLEDIMVAL') 
 CREATE TABLE T_HRCS_USERROLEDIMVAL (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FDIMENSIONID BIGINT DEFAULT 0 NOT NULL,
FISALL CHAR(1) DEFAULT ' ' NOT NULL,
FDIMVAL VARCHAR(500) DEFAULT ' ' NOT NULL,
FCONTAINSSUB CHAR(1) DEFAULT ' ' NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL
);



/**End D:\PDM_UPGRADE\PDM1\HRCS_table.sql **/
