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

Create Table T_LOV_CONST(
Code		VARCHAR(80)		NOT NULL,
Name		VARCHAR(80),
Content		VARCHAR(5000),
toc		TIMESTAMP,
tom		TIMESTAMP,
mop		VARCHAR(120),
mou		VARCHAR(30),
CONSTRAINT pk_T_LOV_CONST PRIMARY KEY (Code)
)
IN TB8KUSREMS INDEX IN TB8KIDXEMS@

COMMENT ON Table T_LOV_CONST IS '常量配置表'@

COMMENT ON T_LOV_CONST (Code IS '代码')@
COMMENT ON T_LOV_CONST (Name IS '代码名称')@
COMMENT ON T_LOV_CONST (Content IS '内容 {   "key":["CPC"，"UPS"，"泵"，"变频器"，"测温"，"电机"，"风机"] }')@

/****************************************************************************
						INSERT TRIGGER FOR TABLE
							  T_LOV_CONST
*****************************************************************************/
DROP TRIGGER ins_b_T_LOV_CONST@

CREATE OR REPLACE TRIGGER ins_b_T_LOV_CONST
BEFORE INSERT ON T_LOV_CONST 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_LOV_CONST
*****************************************************************************/
DROP TRIGGER upd_b_T_LOV_CONST@

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