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

Create Table T_RULE_SAMPLE_MGR(
RuleId		VARCHAR(36)		NOT NULL,
cronresult		DECIMAL(4),
croncount		DECIMAL(8,2),
toc		TIMESTAMP,
tom		TIMESTAMP,
mop		VARCHAR(120),
mou		VARCHAR(30),
CONSTRAINT pk_T_RULE_SAMPLE_MGR PRIMARY KEY (RuleId)
)
IN TB8KUSREMS INDEX IN TB8KIDXEMS@

COMMENT ON Table T_RULE_SAMPLE_MGR IS '统计的定时任务记录表'@

COMMENT ON T_RULE_SAMPLE_MGR (RuleId IS '规则id')@
COMMENT ON T_RULE_SAMPLE_MGR (cronresult IS '定时任务的结果')@
COMMENT ON T_RULE_SAMPLE_MGR (croncount IS '定时任务的次数')@

/****************************************************************************
						INSERT TRIGGER FOR TABLE
							  T_RULE_SAMPLE_MGR
*****************************************************************************/
DROP TRIGGER ins_b_T_RULE_SAMPLE_MGR@

CREATE OR REPLACE TRIGGER ins_b_T_RULE_SAMPLE_MGR
BEFORE INSERT ON T_RULE_SAMPLE_MGR 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_MGR
*****************************************************************************/
DROP TRIGGER upd_b_T_RULE_SAMPLE_MGR@

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