
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_ANALYSERPT_VARVAL')
CREATE TABLE T_EB_ANALYSERPT_VARVAL (
	FID BIGINT DEFAULT 0 NOT NULL,
	FENTRYID BIGINT DEFAULT 0 NOT NULL,
	FSEQ BIGINT  DEFAULT 0 NOT NULL,
	FDIMENSION BIGINT DEFAULT 0 NOT NULL,
	FVARITEM BIGINT DEFAULT 0 NOT NULL ,
	FVARVALID BIGINT DEFAULT 0 NOT NULL 
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_VARVALUSERRECORD')
CREATE TABLE T_EB_VARVALUSERRECORD (
	FID BIGINT DEFAULT 0 NOT NULL,
	FVARID BIGINT DEFAULT 0 NOT NULL,
	FVARVALID BIGINT  DEFAULT 0 NOT NULL,
	FSOURCEID BIGINT  DEFAULT 0 NOT NULL
);


 EXEC P_ALTERPK 'PK_T_EB_ANALYSERPT_VARVAL', 'T_EB_ANALYSERPT_VARVAL', 'FENTRYID', '1';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_EB_ANALYSERPT_VARVAL1') CREATE INDEX IDX_T_EB_ANALYSERPT_VARVAL1 ON T_EB_ANALYSERPT_VARVAL ( FID);
 
 
 EXEC P_ALTERPK 'PK_T_EB_VARVALUSERRECORD', 'T_EB_VARVALUSERRECORD', 'FID', '1';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_EB_VARVALUSERRECORD_S') CREATE INDEX IDX_T_EB_VARVALUSERRECORD_S ON T_EB_VARVALUSERRECORD (FSOURCEID);