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

Create Table T_LOV_TELEITEM(
majNo		DECIMAL(10)		NOT NULL,
minNo		DECIMAL(10)		NOT NULL,
eventno		DECIMAL(10)		NOT NULL,
item		VARCHAR(100),
teleId		VARCHAR(10),
chinese		VARCHAR(100),
factor		VARCHAR(12),
length		DECIMAL(10),
repeat		DECIMAL(10),
datatype		VARCHAR(2),
defaultValue		VARCHAR(10),
flag		VARCHAR(16),
Table1		VARCHAR(40),
column1		VARCHAR(40),
Table2		VARCHAR(40),
column2		VARCHAR(40),
Table3		VARCHAR(40),
column3		VARCHAR(40),
Table4		VARCHAR(40),
column4		VARCHAR(40),
Table5		VARCHAR(40),
column5		VARCHAR(40),
limitDB		VARCHAR(64),
limitMin		VARCHAR(32),
limitMax		VARCHAR(32),
Print		VARCHAR(1),
toc		TIMESTAMP,
tom		TIMESTAMP,
mop		VARCHAR(120),
mou		VARCHAR(30),
CONSTRAINT pk_T_LOV_TELEITEM PRIMARY KEY (majNo, minNo, eventno)
)
IN TB8KUSREMS INDEX IN TB8KIDXEMS@

COMMENT ON Table T_LOV_TELEITEM IS '电文具体定义以及数据去向表'@

COMMENT ON T_LOV_TELEITEM (majNo IS '排序主要数字')@
COMMENT ON T_LOV_TELEITEM (minNo IS '排序辅助数字')@
COMMENT ON T_LOV_TELEITEM (factor IS '转换因素')@
COMMENT ON T_LOV_TELEITEM (length IS '电文中电文长度属性')@
COMMENT ON T_LOV_TELEITEM (flag IS 'flag for processing')@

/****************************************************************************
						INSERT TRIGGER FOR TABLE
							  T_LOV_TELEITEM
*****************************************************************************/
DROP TRIGGER ins_b_T_LOV_TELEITEM@

CREATE OR REPLACE TRIGGER ins_b_T_LOV_TELEITEM
BEFORE INSERT ON T_LOV_TELEITEM 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_TELEITEM
*****************************************************************************/
DROP TRIGGER upd_b_T_LOV_TELEITEM@

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