-- Version:		2025.7.31  14:52:27
Drop Table T_RULE_SAMPLE_FEATURE@

Create Table T_RULE_SAMPLE_FEATURE(
RuleId		VARCHAR(36)		NOT NULL,
Left		DECIMAL(8,2)		NOT NULL,
Right		DECIMAL(8,2),
Mean		VARCHAR(8.2),
StdDev		DECIMAL(8,2),
Skewness		VARCHAR(8.2)		NOT NULL,
Kurtosis		VARCHAR(60),
Variance		VARCHAR(60),
StartTime		TIMESTAMP,
EndTime		TIMESTAMP,
toc		TIMESTAMP,
tom		TIMESTAMP,
mop		VARCHAR(120),
mou		VARCHAR(30),
CONSTRAINT pk_T_RULE_SAMPLE_FEATURE PRIMARY KEY (RuleId, Left)
)
IN TB8KUSREMS INDEX IN TB8KIDXEMS@

COMMENT ON Table T_RULE_SAMPLE_FEATURE IS '统计特征值表'@

COMMENT ON T_RULE_SAMPLE_FEATURE (RuleId IS '规则id')@
COMMENT ON T_RULE_SAMPLE_FEATURE (Left IS '区间左')@
COMMENT ON T_RULE_SAMPLE_FEATURE (Right IS '区间右')@
COMMENT ON T_RULE_SAMPLE_FEATURE (Mean IS '统计均值')@
COMMENT ON T_RULE_SAMPLE_FEATURE (StdDev IS '统计标准差')@
COMMENT ON T_RULE_SAMPLE_FEATURE (Skewness IS '统计偏度')@
COMMENT ON T_RULE_SAMPLE_FEATURE (Kurtosis IS '统计峭度')@
COMMENT ON T_RULE_SAMPLE_FEATURE (Variance IS '统计方差')@
COMMENT ON T_RULE_SAMPLE_FEATURE (StartTime IS '统计开始时间')@
COMMENT ON T_RULE_SAMPLE_FEATURE (EndTime IS '统计结束时间')@

/****************************************************************************
						INSERT TRIGGER FOR TABLE
							  T_RULE_SAMPLE_FEATURE
*****************************************************************************/
DROP TRIGGER ins_b_T_RULE_SAMPLE_FEATURE@

CREATE OR REPLACE TRIGGER ins_b_T_RULE_SAMPLE_FEATURE
BEFORE INSERT ON T_RULE_SAMPLE_FEATURE REFERENCING NEW AS NEWROW FOR EACH ROW
MODE DB2SQL
BEGIN ATOMIC
	DECLARE	programm	VARCHAR(120);
	DECLARE	auth	VARCHAR(30);

	set (programm,auth) = (SELECT APPL_NAME,AUTHID FROM SYSIBMADM.APPLICATIONS WHERE APPL_ID = (SELECT APPLICATION_ID() FROM dual));

	set NEWROW.toc = (values sysdate);
	set NEWROW.tom = (values sysdate);
	set NEWROW.mop = programm;
	set NEWROW.mou = auth;
END
@
/****************************************************************************
						UPDATE TRIGGER FOR TABLE
							  T_RULE_SAMPLE_FEATURE
*****************************************************************************/
DROP TRIGGER upd_b_T_RULE_SAMPLE_FEATURE@

CREATE OR REPLACE TRIGGER upd_b_T_RULE_SAMPLE_FEATURE
BEFORE UPDATE ON T_RULE_SAMPLE_FEATURE REFERENCING NEW AS NEWROW FOR EACH ROW
MODE DB2SQL
BEGIN ATOMIC
	DECLARE	programm	VARCHAR(120);
	DECLARE	auth	VARCHAR(30);

	set (programm,auth) = (SELECT APPL_NAME,AUTHID FROM SYSIBMADM.APPLICATIONS WHERE APPL_ID = (SELECT APPLICATION_ID() FROM dual));

	set NEWROW.tom = (values sysdate);
	set NEWROW.mop = programm;
	set NEWROW.mou = auth;
END
@
