/**Begin D:\PDM_UPGRADE\PDM1\HRCS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_LBLFIELDTYPE') 
 CREATE TABLE T_HRCS_LBLFIELDTYPE (
FID BIGINT DEFAULT 0 NOT NULL,
FLABELOBJECTID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(60) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(2) DEFAULT 'C' NOT NULL,
FENABLE VARCHAR(2) DEFAULT '1' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FSIMPLENAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FINDEX BIGINT DEFAULT 0 NOT NULL,
FISSYSPRESET CHAR(1) DEFAULT '0' NOT NULL,
FDISABLERID BIGINT DEFAULT 0 NOT NULL,
FDISABLEDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_LBLOBJECTFIELD') 
 CREATE TABLE T_HRCS_LBLOBJECTFIELD (
FID BIGINT DEFAULT 0 NOT NULL,
FFIELDNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FENTITYNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FFIELDALIAS VARCHAR(200) DEFAULT ' ' NOT NULL,
FFIELDPATH VARCHAR(200) DEFAULT ' ' NOT NULL,
FVALUETYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FCOMPLEXTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FFIELDTYPEID BIGINT DEFAULT 0 NOT NULL,
FLABELOBJECTID BIGINT DEFAULT 0 NOT NULL,
FBUSINESSOBJECTID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_LBLOBJECTFIELD' AND KSQL_COL_NAME IN ('FISDEFAULTFIELD')) 
 ALTER TABLE T_HRCS_LBLOBJECTFIELD ADD (FISDEFAULTFIELD CHAR(1) DEFAULT '0' NOT NULL );


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_LBLOBJECTFIELD_L') 
 CREATE TABLE T_HRCS_LBLOBJECTFIELD_L (
FPKID VARCHAR(18) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FFIELDNAME NVARCHAR(100) DEFAULT ' ' NOT NULL
);



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


/** dimension table***/

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_LBLDIMENSION') 
 CREATE TABLE T_HRCS_LBLDIMENSION (
FID BIGINT DEFAULT 0 NOT NULL,
FLABELOBJECTID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FINDEX INT DEFAULT 0 NOT NULL,
FSTATUS VARCHAR(2) DEFAULT 'C' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE VARCHAR(2) DEFAULT '1' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FSIMPLENAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FISSYSPRESET CHAR(1) DEFAULT '0' NOT NULL,
FDISABLERID BIGINT DEFAULT 0 NOT NULL,
FDISABLEDATE DATETIME
);



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


/** label scene  **/

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_LABELSCENE') 
 CREATE TABLE T_HRCS_LABELSCENE (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(60) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FBIZAPPID BIGINT DEFAULT 0 NOT NULL,
FPROJECTABILITY VARCHAR(100) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FENABLE VARCHAR(2) DEFAULT '1' NOT NULL,
FSTATUS VARCHAR(2) DEFAULT 'C' NOT NULL,
FDISABLERID BIGINT DEFAULT 0 NOT NULL,
FDISABLEDATE DATETIME,
FINDEX INT DEFAULT 0 NOT NULL,
FISSYSPRESET CHAR(1) DEFAULT '0' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FSIMPLENAME NVARCHAR(100) DEFAULT ' ' NOT NULL
);


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

/**FBIZAPPID   varchar ***/
EXEC p_AlterColumn 'T_HRCS_LABELSCENE', 'FBIZAPPID', 'VARCHAR(50)', 'NOT NULL', '1111', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_LBLSCENEOBJECTIDS') 
 CREATE TABLE T_HRCS_LBLSCENEOBJECTIDS (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);

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