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

Create Table T_EQP_GROUP(
EquipGroup		VARCHAR(50)		NOT NULL,
EquipName		VARCHAR(50)		NOT NULL,
RuleId		VARCHAR(50),
EquipGName		VARCHAR(100),
toc		TIMESTAMP,
tom		TIMESTAMP,
mop		VARCHAR(120),
mou		VARCHAR(30),
CONSTRAINT pk_T_EQP_GROUP PRIMARY KEY (EquipGroup, EquipName)
)
IN TB8KUSREMS INDEX IN TB8KIDXEMS@

COMMENT ON Table T_EQP_GROUP IS '设备大分类'@

COMMENT ON T_EQP_GROUP (EquipGroup IS '设备大类(如CPC，UPS，泵，变频器，测温回路，柴油发电机，电机，风机)')@
COMMENT ON T_EQP_GROUP (EquipName IS '设备名称(如BR1，BR2，BR3)')@
COMMENT ON T_EQP_GROUP (RuleId IS '规则ID')@
COMMENT ON T_EQP_GROUP (EquipGName IS '设备大类描述')@

/****************************************************************************
						INSERT TRIGGER FOR TABLE
							  T_EQP_GROUP
*****************************************************************************/
DROP TRIGGER ins_b_T_EQP_GROUP@

CREATE OR REPLACE TRIGGER ins_b_T_EQP_GROUP
BEFORE INSERT ON T_EQP_GROUP 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_EQP_GROUP
*****************************************************************************/
DROP TRIGGER upd_b_T_EQP_GROUP@

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