/**Begin D:\work\kuaijishijian\pdm\PDM_UPGRADE_1.4\PDM_UPGRADE\PDM1\AI_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FAH_VALMAP_TYPE' AND KSQL_COL_NAME ='FGROUPID')
 ALTER TABLE T_FAH_VALMAP_TYPE ADD (FGROUPID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FAH_VALMAP_TYPE' AND KSQL_COL_NAME ='FSTATUS')
 ALTER TABLE T_FAH_VALMAP_TYPE ADD (FSTATUS CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FAH_FLEX_MAPVAL' AND KSQL_COL_NAME ='FGROUPID')
 ALTER TABLE T_FAH_FLEX_MAPVAL ADD (FGROUPID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FAH_FLEX_MAPVAL' AND KSQL_COL_NAME ='FOWNORGID')
 ALTER TABLE T_FAH_FLEX_MAPVAL ADD (FOWNORGID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FAH_FLEX_MAPVAL' AND KSQL_COL_NAME ='FORGTYPE')
 ALTER TABLE T_FAH_FLEX_MAPVAL ADD (FORGTYPE VARCHAR(2) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FAH_FLEX_MAPVAL' AND KSQL_COL_NAME ='FCREATETIME')
 ALTER TABLE T_FAH_FLEX_MAPVAL ADD (FCREATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FAH_FLEX_MAPVAL' AND KSQL_COL_NAME ='FCREATORID')
 ALTER TABLE T_FAH_FLEX_MAPVAL ADD (FCREATORID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FAH_FLEX_MAPVAL' AND KSQL_COL_NAME ='FMODIFYTIME')
 ALTER TABLE T_FAH_FLEX_MAPVAL ADD (FMODIFYTIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FAH_FLEX_MAPVAL' AND KSQL_COL_NAME ='FMODIFIERID')
 ALTER TABLE T_FAH_FLEX_MAPVAL ADD (FMODIFIERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FAH_FLEX_VAL_TMP' AND KSQL_COL_NAME ='FGROUPID')
 ALTER TABLE T_FAH_FLEX_VAL_TMP ADD (FGROUPID VARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FAH_FLEX_VAL_TMP' AND KSQL_COL_NAME ='FOWNORGID')
 ALTER TABLE T_FAH_FLEX_VAL_TMP ADD (FOWNORGID VARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FAH_FLEX_VAL_TMP' AND KSQL_COL_NAME ='FORGTYPE')
 ALTER TABLE T_FAH_FLEX_VAL_TMP ADD (FORGTYPE VARCHAR(2) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_VALMAP_TYPE_GROUP_L')
 CREATE TABLE T_FAH_VALMAP_TYPE_GROUP_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FFULLNAME NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_VALMAP_TYPE_GROUP')
 CREATE TABLE T_FAH_VALMAP_TYPE_GROUP (
FID BIGINT DEFAULT 0 NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FLONGNUMBER NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FENABLE CHAR(1) DEFAULT ' ' NOT NULL,
FLEVEL INT DEFAULT 0 NOT NULL,
FISLEAF CHAR(1) DEFAULT ' ' NOT NULL,
FPARENTID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_VALMAP_TYPE_ORG')
 CREATE TABLE T_FAH_VALMAP_TYPE_ORG (
FID BIGINT DEFAULT 0 NOT NULL,
FMAPTYPEID BIGINT DEFAULT 0 NOT NULL,
FOWNORGID BIGINT DEFAULT 0 NOT NULL,
FORGTYPE VARCHAR(2) DEFAULT ' ' NOT NULL,
FISCUSTOM CHAR(1) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_FLEX_MAPVAL_TMP')
 CREATE TABLE T_FAH_FLEX_MAPVAL_TMP (
FTMPID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FMAPTYPEID BIGINT DEFAULT 0 NOT NULL,
FGROUPID BIGINT DEFAULT 0 NOT NULL,
FOWNORGID BIGINT DEFAULT 0 NOT NULL,
FORGTYPE VARCHAR(2) DEFAULT ' ' NOT NULL,
FSERIALNUMBER INT DEFAULT 0 NOT NULL,
FHASHCODE BIGINT DEFAULT 0 NOT NULL,
FENABLE CHAR(1) DEFAULT ' ' NOT NULL,
FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FEFFECTDATE DATETIME,
FEXPIREDATE DATETIME,
FMAPVALUETYPE CHAR(1) DEFAULT ' ' NOT NULL,
FHASMULVALUE CHAR(1) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FPAGEID VARCHAR(255) DEFAULT ' ' NOT NULL,
FCHANGETYPE CHAR(1) DEFAULT ' ' NOT NULL,
FTXTATTR1 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FTXTATTR2 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FTXTATTR3 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FTXTATTR4 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FTXTATTR5 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FTXTATTR6 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FTXTATTR7 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FTXTATTR8 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FTXTATTR9 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FTXTATTR10 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FTXTATTR11 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FTXTATTR12 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FTXTATTR13 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FTXTATTR14 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FTXTATTR15 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FIDATTR1 BIGINT DEFAULT 0 NOT NULL,
FIDATTR2 BIGINT DEFAULT 0 NOT NULL,
FIDATTR3 BIGINT DEFAULT 0 NOT NULL,
FIDATTR4 BIGINT DEFAULT 0 NOT NULL,
FIDATTR5 BIGINT DEFAULT 0 NOT NULL,
FIDATTR6 BIGINT DEFAULT 0 NOT NULL,
FIDATTR7 BIGINT DEFAULT 0 NOT NULL,
FIDATTR8 BIGINT DEFAULT 0 NOT NULL,
FIDATTR9 BIGINT DEFAULT 0 NOT NULL,
FIDATTR10 BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_FLEX_MAPVAL_HIS')
 CREATE TABLE T_FAH_FLEX_MAPVAL_HIS (
FID BIGINT DEFAULT 0 NOT NULL,
FMAPTYPEID BIGINT DEFAULT 0 NOT NULL,
FGROUPID BIGINT DEFAULT 0 NOT NULL,
FOWNORGID BIGINT DEFAULT 0 NOT NULL,
FORGTYPE VARCHAR(2) DEFAULT ' ' NOT NULL,
FSERIALNUMBER INT DEFAULT 0 NOT NULL,
FHASHCODE BIGINT DEFAULT 0 NOT NULL,
FENABLE CHAR(1) DEFAULT ' ' NOT NULL,
FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FEFFECTDATE DATETIME,
FEXPIREDATE DATETIME,
FMAPVALUETYPE CHAR(1) DEFAULT ' ' NOT NULL,
FHASMULVALUE CHAR(1) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FCHANGETYPE CHAR(1) DEFAULT ' ' NOT NULL,
FTXTATTR1 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FTXTATTR2 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FTXTATTR3 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FTXTATTR4 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FTXTATTR5 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FTXTATTR6 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FTXTATTR7 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FTXTATTR8 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FTXTATTR9 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FTXTATTR10 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FTXTATTR11 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FTXTATTR12 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FTXTATTR13 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FTXTATTR14 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FTXTATTR15 NVARCHAR(150) DEFAULT ' ' NOT NULL,
FIDATTR1 BIGINT DEFAULT 0 NOT NULL,
FIDATTR2 BIGINT DEFAULT 0 NOT NULL,
FIDATTR3 BIGINT DEFAULT 0 NOT NULL,
FIDATTR4 BIGINT DEFAULT 0 NOT NULL,
FIDATTR5 BIGINT DEFAULT 0 NOT NULL,
FIDATTR6 BIGINT DEFAULT 0 NOT NULL,
FIDATTR7 BIGINT DEFAULT 0 NOT NULL,
FIDATTR8 BIGINT DEFAULT 0 NOT NULL,
FIDATTR9 BIGINT DEFAULT 0 NOT NULL,
FIDATTR10 BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_BGTASK_LOG')
 CREATE TABLE T_FAH_BGTASK_LOG (
FID BIGINT DEFAULT 0 NOT NULL,
FTASKTYPE VARCHAR(5) DEFAULT ' ' NOT NULL,
FTASKNAME NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCOMPTIME DATETIME,
FINSTANCEID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTOTALWORKPOINT INT DEFAULT 0 NOT NULL,
FCMPWORKPOINT INT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FTASKSTATUS CHAR(1) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_BGTASK_LOG_DETAIL')
 CREATE TABLE T_FAH_BGTASK_LOG_DETAIL (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FLOGLEVEL CHAR(1) DEFAULT ' ' NOT NULL,
FTASKSTEPSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FMSG VARCHAR(255) DEFAULT ' ',
FMSG_TAG NCLOB
);



/**End D:\work\kuaijishijian\pdm\PDM_UPGRADE_1.4\PDM_UPGRADE\PDM1\AI_table.sql **/
