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

Create Table T_LOG_INFO(
SeqNo		DECIMAL(10)		NOT NULL,
extId		VARCHAR(20),
HostName		VARCHAR(30),
Information		VARCHAR(255),
IPADDR		VARCHAR(30),
LogLevel		DECIMAL(10),
LogTime		TIMESTAMP,
Module		VARCHAR(50),
UserID		VARCHAR(25),
toc		TIMESTAMP,
tom		TIMESTAMP,
mop		VARCHAR(120),
mou		VARCHAR(30),
CONSTRAINT pk_T_LOG_INFO PRIMARY KEY (SeqNo)
)
IN TB8KUSREMS INDEX IN TB8KIDXEMS@

COMMENT ON Table T_LOG_INFO IS '画面日志表'@

COMMENT ON T_LOG_INFO (SeqNo IS '序号')@
COMMENT ON T_LOG_INFO (extId IS '钢卷号')@

/****************************************************************************
						INSERT TRIGGER FOR TABLE
							  T_LOG_INFO
*****************************************************************************/
DROP TRIGGER ins_b_T_LOG_INFO@

CREATE OR REPLACE TRIGGER ins_b_T_LOG_INFO
BEFORE INSERT ON T_LOG_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_LOG_INFO
*****************************************************************************/
DROP TRIGGER upd_b_T_LOG_INFO@

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