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

Create Table T_LOV_PARAM(
paramName		VARCHAR(60)		NOT NULL,
plantType		VARCHAR(3)		NOT NULL,
cType		VARCHAR(12),
curValC		VARCHAR(100),
curValN		DECIMAL(12,2),
description		VARCHAR(254)		NOT NULL,
limitNameLl		VARCHAR(60),
limitNameUl		VARCHAR(60),
moddescr		VARCHAR(254),
sortOrder		VARCHAR(10),
unit		VARCHAR(10)		NOT NULL,
toc		TIMESTAMP,
tom		TIMESTAMP,
mop		VARCHAR(120),
mou		VARCHAR(30),
CONSTRAINT pk_T_LOV_PARAM PRIMARY KEY (paramName, plantType)
)
IN TB8KUSREMS INDEX IN TB8KIDXEMS@

COMMENT ON Table T_LOV_PARAM IS '设备参数表'@

COMMENT ON T_LOV_PARAM (paramName IS 'name of the parameter')@
COMMENT ON T_LOV_PARAM (plantType IS 'Plant type TCM/RCM/SPM ... Usw')@
COMMENT ON T_LOV_PARAM (cType IS 'type of the value')@
COMMENT ON T_LOV_PARAM (curValC IS 'character value')@
COMMENT ON T_LOV_PARAM (curValN IS 'numeric value')@
COMMENT ON T_LOV_PARAM (description IS 'description')@
COMMENT ON T_LOV_PARAM (limitNameLl IS 'name of the lower limit value')@
COMMENT ON T_LOV_PARAM (limitNameUl IS 'name of the upper limit value')@
COMMENT ON T_LOV_PARAM (moddescr IS 'description of the modification')@
COMMENT ON T_LOV_PARAM (sortOrder IS 'sort order')@
COMMENT ON T_LOV_PARAM (unit IS 'unit of the value')@

/****************************************************************************
						INSERT TRIGGER FOR TABLE
							  T_LOV_PARAM
*****************************************************************************/
DROP TRIGGER ins_b_T_LOV_PARAM@

CREATE OR REPLACE TRIGGER ins_b_T_LOV_PARAM
BEFORE INSERT ON T_LOV_PARAM 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_PARAM
*****************************************************************************/
DROP TRIGGER upd_b_T_LOV_PARAM@

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