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

Create Table T_RULE_SAMPLE_2D_INFO(
RuleId		VARCHAR(36)		NOT NULL,
Range1		DECIMAL(8,2),
Spare1		DECIMAL(8,2),
Range2		DECIMAL(8,2),
Spare2		DECIMAL(8,2),
toc		TIMESTAMP,
tom		TIMESTAMP,
mop		VARCHAR(120),
mou		VARCHAR(30),
CONSTRAINT pk_T_RULE_SAMPLE_2D_INFO PRIMARY KEY (RuleId)
)
IN TB8KUSREMS INDEX IN TB8KIDXEMS@

COMMENT ON Table T_RULE_SAMPLE_2D_INFO IS '统计2维样本的数据信息表'@

COMMENT ON T_RULE_SAMPLE_2D_INFO (RuleId IS '规则id')@
COMMENT ON T_RULE_SAMPLE_2D_INFO (Range1 IS '统计1区间中点')@
COMMENT ON T_RULE_SAMPLE_2D_INFO (Spare1 IS '保留字段1')@
COMMENT ON T_RULE_SAMPLE_2D_INFO (Range2 IS '统计2区间中点')@
COMMENT ON T_RULE_SAMPLE_2D_INFO (Spare2 IS '保留字段2')@

/****************************************************************************
						INSERT TRIGGER FOR TABLE
							  T_RULE_SAMPLE_2D_INFO
*****************************************************************************/
DROP TRIGGER ins_b_T_RULE_SAMPLE_2D_INFO@

CREATE OR REPLACE TRIGGER ins_b_T_RULE_SAMPLE_2D_INFO
BEFORE INSERT ON T_RULE_SAMPLE_2D_INFO 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_2D_INFO
*****************************************************************************/
DROP TRIGGER upd_b_T_RULE_SAMPLE_2D_INFO@

CREATE OR REPLACE TRIGGER upd_b_T_RULE_SAMPLE_2D_INFO
BEFORE UPDATE ON T_RULE_SAMPLE_2D_INFO 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
@
