/**BEGIN**/

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_EXAMINE_NEW_REPORT')
CREATE TABLE T_EB_EXAMINE_NEW_REPORT
(
    FID             BIGINT DEFAULT 0 NOT NULL,
    FSTATUS         NVARCHAR(50) DEFAULT ' ' NOT NULL,
    FEXAMINE        BIGINT DEFAULT 0 NOT NULL,
    FLEFTVALUE      NVARCHAR(50) DEFAULT ' ' NOT NULL,
    FRIGHTVALUE     NVARCHAR(50) DEFAULT ' ' NOT NULL,
    FDIFFERENCE     NVARCHAR(50) DEFAULT ' ' NOT NULL,
    FENTITY         BIGINT DEFAULT 0 NOT NULL,
    FPERIOD         BIGINT DEFAULT 0 NOT NULL,
    FACCOUNT        BIGINT DEFAULT 0 NOT NULL,
    FDIMRANGE       NCLOB,
    FREMARK         NVARCHAR(255) DEFAULT ' ' NOT NULL,
    FANNOTATOR      BIGINT DEFAULT 0 NOT NULL,
    FANNOTATETIME   DATETIME,
    FEXAMINETIME    DATETIME,
    FMODEL          BIGINT DEFAULT 0 NOT NULL,
    FVERSION        BIGINT DEFAULT 0 NOT NULL,
    FDATATYPE       BIGINT DEFAULT 0 NOT NULL,
    FEXECUTETYPE    NVARCHAR(50) DEFAULT ' ' NOT NULL,
    FCREATER        BIGINT DEFAULT 0 NOT NULL,
    FREPORTPROCESS  BIGINT DEFAULT 0 NOT NULL,
    FPROCESSTYPE    NVARCHAR(50) DEFAULT ' ' NOT NULL,
    FTEMPLATE       BIGINT DEFAULT 0 NOT NULL,
    FANNOTATION     BIGINT DEFAULT 0 NOT NULL,
    FDETAILVERSION  BIGINT DEFAULT 0 NOT NULL,
    FDETAILENTITY   BIGINT DEFAULT 0 NOT NULL,
    FDETAILPERIOD   BIGINT DEFAULT 0 NOT NULL,
    FDETAILDATATYPE BIGINT DEFAULT 0 NOT NULL,
	FDATASET  		BIGINT DEFAULT 0 NOT NULL
);

-- 主键
EXEC P_ALTERPK 'PK_T_EB_EXAMINE_NEW_REPORT', 'T_EB_EXAMINE_NEW_REPORT', 'FID', '1';
-- 索引
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_EXAMINE_NEW_REPORT_UN')
CREATE INDEX IDX_EB_EXAMINE_NEW_REPORT_UN ON T_EB_EXAMINE_NEW_REPORT ( FMODEL,FPERIOD,FDATATYPE,FVERSION,FENTITY);



IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_EXAMINE_VALUE')
CREATE TABLE T_EB_EXAMINE_VALUE
(
    FID            BIGINT DEFAULT 0 NOT NULL,
    FENTRYID       BIGINT DEFAULT 0 NOT NULL,
    FSEQ           INTEGER DEFAULT 0 NOT NULL,
    FPARENTENTRYID BIGINT DEFAULT 0 NOT NULL,
    FVALUE         NVARCHAR(50) DEFAULT ' ' NOT NULL,
    FEXAMINETYPE   NVARCHAR(50) DEFAULT ' ' NOT NULL,
    FDIMJSON       NCLOB,
    FDIMJSON_TAG   NCLOB,
    FNAME          NVARCHAR(255) DEFAULT ' ' NOT NULL,
	FMEMBERKEY     NVARCHAR(50) DEFAULT ' ' NOT NULL
);

-- 主键
EXEC P_ALTERPK 'PK_T_EB_EXAMINE_VALUE', 'T_EB_EXAMINE_VALUE', 'FENTRYID', '1';
-- 索引
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_EB_EXAMINE_VALUE_FID')
CREATE INDEX IDX_T_EB_EXAMINE_VALUE_FID ON T_EB_EXAMINE_VALUE (FID);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_EXAMINE_ANNOTATION' AND KSQL_COL_NAME IN ('FEXAMINE')) 
 ALTER TABLE T_EB_EXAMINE_ANNOTATION ADD (FEXAMINE BIGINT DEFAULT 0 NOT NULL);

/**END**/