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

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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_DYNAPUBLISHERDS') 
 CREATE TABLE T_HRCS_DYNAPUBLISHERDS (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(60) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
FENABLE VARCHAR(2) DEFAULT ' ' NOT NULL,
FSIMPLENAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FORINUMBER VARCHAR(60) DEFAULT ' ' NOT NULL,
FORINAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FORISTATUS VARCHAR(10) DEFAULT ' ' NOT NULL,
FSOURCECLASSIFY VARCHAR(10) DEFAULT ' ' NOT NULL,
FENTITYTYPEID VARCHAR(36) DEFAULT ' ' NOT NULL,
FAPISOURCEID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FINDEX INT 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_DYNAPUBLISHERS') 
 CREATE TABLE T_HRCS_DYNAPUBLISHERS (
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_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_DYNAPUBLISHERPAR') 
 CREATE TABLE T_HRCS_DYNAPUBLISHERPAR (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FINPUTPARAMENTRYID BIGINT DEFAULT 0 NOT NULL,
FAPISOURCEID BIGINT DEFAULT 0 NOT NULL,
FAPIFIELDKEY VARCHAR(255) DEFAULT ' ' NOT NULL,
FAPIFIELDNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_DYNAPUBLISHERDS_L') 
 CREATE TABLE T_HRCS_DYNAPUBLISHERDS_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,
FORINAME NVARCHAR(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_DYNAFORMULA_L') 
 CREATE TABLE T_HRCS_DYNAFORMULA_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_DYNAFORMULA') 
 CREATE TABLE T_HRCS_DYNAFORMULA (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(60) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
FENABLE VARCHAR(2) DEFAULT ' ' NOT NULL,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FUSEORGID BIGINT DEFAULT 0 NOT NULL,
FCTRLSTRATEGY VARCHAR(2) DEFAULT ' ' NOT NULL,
FSRCCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FSIMPLENAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FBOID BIGINT DEFAULT 0 NOT NULL,
FISCURRENTVERSION CHAR(1) DEFAULT '0' NOT NULL,
FDATASTATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
FSOURCEVID BIGINT DEFAULT 0 NOT NULL,
FFIRSTBSED DATETIME,
FCHANGEBSED DATETIME,
FBRED DATETIME,
FBRLED DATETIME,
FBRFD DATETIME,
FISMODIFY CHAR(1) DEFAULT '0' NOT NULL,
FBSED DATETIME,
FBSLED DATETIME,
FCHANGEDESCRIPTION VARCHAR(255) DEFAULT ' ' NOT NULL,
FHISVERSION VARCHAR(10) DEFAULT ' ' NOT NULL,
FVERSIONSOURCE VARCHAR(10) DEFAULT ' ' NOT NULL,
FRESULTITEMID VARCHAR(36) DEFAULT ' ' NOT NULL,
FORIGINALEXP NCLOB,
FEXECUTEEXP NCLOB,
FDEPENDENTFUNC NCLOB,
FISDRAFT CHAR(1) DEFAULT '0' NOT NULL,
FDEPENDENTCALITEM NCLOB,
FDEPENDENTCUSTITEM NCLOB,
FDEPENDENTCALITEMFORFUNC NCLOB,
FRESULTITEMCATEGORY VARCHAR(54) DEFAULT ' ' NOT NULL,
FRESULTITEMUNIQUECODE VARCHAR(50) DEFAULT ' ' NOT NULL,
FRESULTITEMDATATYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FRESULTITEMDATALENGTH INT DEFAULT 0 NOT NULL,
FRESULTITEMSCALE INT DEFAULT 0 NOT NULL,
FUNIQUECODEEXP NCLOB,
FDEPENDENTCALITEMFORDG NCLOB,
FDEPENDENTDATAGRADE NCLOB,
FDEPENDENTBASEDATA NCLOB,
FDEPENDENTENUM NCLOB,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FINDEX INT 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_DYNADSPERSONITEM') 
 CREATE TABLE T_HRCS_DYNADSPERSONITEM (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(60) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
FENABLE VARCHAR(2) DEFAULT ' ' NOT NULL,
FSIMPLENAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FINDEX INT 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_DYNADSPERSONITEM_L') 
 CREATE TABLE T_HRCS_DYNADSPERSONITEM_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_DYNASEARCHSCENEA') 
 CREATE TABLE T_HRCS_DYNASEARCHSCENEA (
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_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_DYNASEARCHSCENEC') 
 CREATE TABLE T_HRCS_DYNASEARCHSCENEC (
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_USERTABLES WHERE KSQL_TABNAME = 'T_HRCS_DYNADSPARAMENTITY') 
 CREATE TABLE T_HRCS_DYNADSPARAMENTITY (
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FPROPKEY VARCHAR(255) DEFAULT ' ' NOT NULL,
FPROPNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPUBLISHERDSID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_DYNADSPARAMENTRY' AND KSQL_COL_NAME IN ('FFETCHMODE')) 
 ALTER TABLE T_HRCS_DYNADSPARAMENTRY ADD (FFETCHMODE VARCHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_DYNADSPARAMENTRY' AND KSQL_COL_NAME IN ('FPUBLISHERDSID')) 
 ALTER TABLE T_HRCS_DYNADSPARAMENTRY ADD (FPUBLISHERDSID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_DYNADSPARAMENTRY' AND KSQL_COL_NAME IN ('FDYNAFORMULAID')) 
 ALTER TABLE T_HRCS_DYNADSPARAMENTRY ADD (FDYNAFORMULAID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_DYNADSPARAMENTRY' AND KSQL_COL_NAME IN ('FISSYSPRESET')) 
 ALTER TABLE T_HRCS_DYNADSPARAMENTRY ADD (FISSYSPRESET CHAR(1) DEFAULT '0' NOT NULL );
 EXEC p_AlterColumn 'T_HRCS_DYNADSPARAMENTRY', 'FPROPKEY', 'VARCHAR(255)', 'NOT NULL', '0100', ''' ''';
 EXEC p_AlterColumn 'T_HRCS_DYNADSPARAMENTRY', 'FPROPNAME', 'NVARCHAR(255)', 'NOT NULL', '0100', ''' ''';
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_DYNARULEPARAM' AND KSQL_COL_NAME IN ('FISRELATPARAM')) 
 ALTER TABLE T_HRCS_DYNARULEPARAM ADD (FISRELATPARAM CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_DYNARULEPARAM' AND KSQL_COL_NAME IN ('FRELATRULEPARAMID')) 
 ALTER TABLE T_HRCS_DYNARULEPARAM ADD (FRELATRULEPARAMID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_DYNARULEPARAM' AND KSQL_COL_NAME IN ('FRELATPROPKEY')) 
 ALTER TABLE T_HRCS_DYNARULEPARAM ADD (FRELATPROPKEY VARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_DYNASCENE' AND KSQL_COL_NAME IN ('FAUTHACTION')) 
 ALTER TABLE T_HRCS_DYNASCENE ADD (FAUTHACTION VARCHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_DYNADSPERSONENTRY' AND KSQL_COL_NAME IN ('FENTITYTYPEID')) 
 ALTER TABLE T_HRCS_DYNADSPERSONENTRY ADD (FENTITYTYPEID VARCHAR(36) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_DYNADSPERSONENTRY' AND KSQL_COL_NAME IN ('FPERSONNAMEITEMID')) 
 ALTER TABLE T_HRCS_DYNADSPERSONENTRY ADD (FPERSONNAMEITEMID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_DYNASCHEME' AND KSQL_COL_NAME IN ('FRULEDESCRIPTION')) 
 ALTER TABLE T_HRCS_DYNASCHEME ADD (FRULEDESCRIPTION NVARCHAR(2000) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_DYNASCHEME_L' AND KSQL_COL_NAME IN ('FRULEDESCRIPTION')) 
 ALTER TABLE T_HRCS_DYNASCHEME_L ADD (FRULEDESCRIPTION NVARCHAR(2000) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_DYNADATASOURCE' AND KSQL_COL_NAME IN ('FMSGPUBLISHERID')) 
 ALTER TABLE T_HRCS_DYNADATASOURCE ADD (FMSGPUBLISHERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_DYNADATASOURCE' AND KSQL_COL_NAME IN ('FISCANCELDS')) 
 ALTER TABLE T_HRCS_DYNADATASOURCE ADD (FISCANCELDS CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_DYNASCHEMECANCEL' AND KSQL_COL_NAME IN ('FCANCELPERSONITEMID')) 
 ALTER TABLE T_HRCS_DYNASCHEMECANCEL ADD (FCANCELPERSONITEMID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_DYNASCHEMESCENE' AND KSQL_COL_NAME IN ('FASSIGNPERSONITEMID')) 
 ALTER TABLE T_HRCS_DYNASCHEMESCENE ADD (FASSIGNPERSONITEMID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_DYNADATASOURCE' AND KSQL_COL_NAME IN ('FNUMBER')) 
 ALTER TABLE T_HRCS_DYNADATASOURCE ADD (FNUMBER VARCHAR(60) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HRCS_DYNADSPARAMENTRY' AND KSQL_COL_NAME IN ('FFETCHSOURCE')) 
 ALTER TABLE T_HRCS_DYNADSPARAMENTRY ADD (FFETCHSOURCE VARCHAR(10) DEFAULT ' ' NOT NULL );
 
 
/**End D:\PDM_UPGRADE\PDM1\HRCS_table.sql **/
