/**Begin D:\utils\PDM_UPGRADE\PDM_UPGRADE\PDM1\HRCS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_FUNCTION')
 CREATE TABLE T_HRCS_FUNCTION (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE VARCHAR(2) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FGROUPID BIGINT DEFAULT 0 NOT NULL,
FDISABLERID BIGINT DEFAULT 0 NOT NULL,
FDISABLEDATE DATETIME,
FDEFINE VARCHAR(50) DEFAULT ' ' NOT NULL,
FFUNCDATATYPE VARCHAR(20) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FUNIQUECODE VARCHAR(50) DEFAULT ' ' NOT NULL,
FEXAMPLE NVARCHAR(1500) DEFAULT ' ' NOT NULL,
FFUNCEXP NCLOB
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_FUNCTIONPARAMS')
 CREATE TABLE T_HRCS_FUNCTIONPARAMS (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FPARAMDATATYPE VARCHAR(20) DEFAULT ' ' NOT NULL,
FPARAMNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPARAMDESC NVARCHAR(255) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_FUNCTIONPARAMS_L')
 CREATE TABLE T_HRCS_FUNCTIONPARAMS_L (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FPKID VARCHAR(18) DEFAULT ' ' NOT NULL,
FPARAMNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPARAMDESC NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_FUNCTIONIMPORT')
 CREATE TABLE T_HRCS_FUNCTIONIMPORT (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FIMPORTCODE VARCHAR(250) DEFAULT ' ' NOT NULL,
FIMPORTPACKAGEDESC NVARCHAR(255) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_FUNCTIONIMPORT_L')
 CREATE TABLE T_HRCS_FUNCTIONIMPORT_L (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FPKID VARCHAR(18) DEFAULT ' ' NOT NULL,
FIMPORTPACKAGEDESC NVARCHAR(255) DEFAULT ' ' NOT NULL
);


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


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


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

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

-- 修改多语言字段长度
EXEC p_AlterColumn 'T_HRCS_FUNCTION', 'FDESCRIPTION', 'NVARCHAR(1500)', 'NOT NULL', '0100', ''' ''';

EXEC p_AlterColumn 'T_HRCS_FUNCTION_L', 'FDESCRIPTION', 'NVARCHAR(1500)', 'NOT NULL', '0100', ''' ''';

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