/**Begin D:\utils\PDM_UPGRADE\PDM_UPGRADE\PDM1\HRCS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HBP_CALRESULTITEM')
 CREATE TABLE T_HBP_CALRESULTITEM (
FID VARCHAR(36) DEFAULT ' ' 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 VARCHAR(36) DEFAULT ' ' 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,
FITEMCATEGORY VARCHAR(50) DEFAULT ' ' NOT NULL,
FUNIQUECODE VARCHAR(255) DEFAULT ' ' NOT NULL,
FDATATYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FDATALENGTH INT DEFAULT 0 NOT NULL,
FSCALE INT DEFAULT 0 NOT NULL,
FISSUBSECTIONITEM VARCHAR(10) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HBP_CALRESULTITEM_L')
 CREATE TABLE T_HBP_CALRESULTITEM_L (
FID VARCHAR(36) DEFAULT ' ' 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
);

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


EXEC p_AlterPK 'PK_HBP_CALRESULTITEM', 'T_HBP_CALRESULTITEM', 'FID', '1';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_HBP_CALRESULTITEM_FNUMBER') CREATE INDEX IDX_HBP_CALRESULTITEM_FNUMBER ON T_HBP_CALRESULTITEM ( FNUMBER );

EXEC p_AlterPK 'PK_HBP_CALRESULTITEM_L', 'T_HBP_CALRESULTITEM_L', 'FPKID', '1';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_HBP_CALRESULTITEM_L') CREATE INDEX IDX_HBP_CALRESULTITEM_L ON T_HBP_CALRESULTITEM_L ( FLOCALEID ,FID );


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HBP_CALRESULTITEM' AND KSQL_COL_NAME ='FENTITYNUMBER')
ALTER TABLE T_HBP_CALRESULTITEM ADD (FENTITYNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HBP_CALRESULTITEM' AND KSQL_COL_NAME ='FPROPERTYFIELD')
ALTER TABLE T_HBP_CALRESULTITEM ADD (FPROPERTYFIELD VARCHAR(50) DEFAULT ' ' NOT NULL );