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

Create Table T_LOV_TELE(
EventNo		DECIMAL(10)		NOT NULL,
Sender		VARCHAR(10),
Receiver		VARCHAR(10),
TeleId		VARCHAR(10)		NOT NULL,
TeleDesc		VARCHAR(100),
Line		DECIMAL(10),
HeaderType		DECIMAL(10),
HeaderLength		DECIMAL(10),
TotalLength		DECIMAL(10),
PrintType		DECIMAL(10),
toc		TIMESTAMP,
tom		TIMESTAMP,
mop		VARCHAR(120),
mou		VARCHAR(30),
CONSTRAINT pk_T_LOV_TELE PRIMARY KEY (EventNo)
)
IN TB8KUSREMS INDEX IN TB8KIDXEMS@

COMMENT ON Table T_LOV_TELE IS '电文常数定义表'@

COMMENT ON T_LOV_TELE (EventNo IS '事件号（1000-2000、2000-3000）')@
COMMENT ON T_LOV_TELE (Sender IS '电文发送方')@
COMMENT ON T_LOV_TELE (Receiver IS '电文接受方')@
COMMENT ON T_LOV_TELE (TeleId IS '电文号')@
COMMENT ON T_LOV_TELE (TeleDesc IS '电文描述')@
COMMENT ON T_LOV_TELE (Line IS '电文所在回线号')@
COMMENT ON T_LOV_TELE (HeaderType IS '电文头')@
COMMENT ON T_LOV_TELE (HeaderLength IS '电文头长度')@
COMMENT ON T_LOV_TELE (TotalLength IS '总电文长度，包括电文头和结束符')@
COMMENT ON T_LOV_TELE (PrintType IS '0:不打印，1:打印日志')@

/****************************************************************************
						INSERT TRIGGER FOR TABLE
							  T_LOV_TELE
*****************************************************************************/
DROP TRIGGER ins_b_T_LOV_TELE@

CREATE OR REPLACE TRIGGER ins_b_T_LOV_TELE
BEFORE INSERT ON T_LOV_TELE 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_TELE
*****************************************************************************/
DROP TRIGGER upd_b_T_LOV_TELE@

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