CREATE EVENT MONITOR mylockevmon
FOR LOCKING WRITE TO TABLE LOCK (TABLE mylockevmon.LOCK), LOCK_PARTICIPANTS (TABLE mylockevmon.LOCK_PARTICIPANTS), LOCK_PARTICIPANT_ACTIVITIES (TABLE mylockevmon.LOCK_PARTICIPANT_ACTIVITIES), LOCK_ACTIVITY_VALUES (TABLE mylockevmon.LOCK_ACTIVITY_VALUES), CONTROL (TABLE mylockevmon.CONTROL);
SET EVENT MONITOR mylockevmon STATE 1;
SELECT
ACT.MEMBER
,ACT.EVENT_TIMESTAMP
,substr(rtrim(PART.table_schema)||'.'||PART.table_name,1,40) as tabela
,PART.APPL_ID,PART.AUTH_ID
,CASE
WHEN LENGTH(ACT.STMT_TEXT) > 807 THEN
X'0A' || SUBSTR(rtrim(REPLACE(ACT.STMT_TEXT,X'0A',' ')),1,350) || ' (...) ' || SUBSTR(RIGHT(REPLACE(ACT.STMT_TEXT,X'0A',' '),450),1,450)
ELSE
X'0A' || SUBSTR(rtrim(REPLACE(ACT.STMT_TEXT,X'0A',' ')),1,807)
END AS STMT_TEXT
FROM
ADILSON.LOCK_PARTICIPANTS PART, ADILSON.LOCK_PARTICIPANT_ACTIVITIES ACT
WHERE ACT.EVENT_ID = PART.EVENT_ID AND
ACT.PARTICIPANT_NO = PART.PARTICIPANT_NO
AND ACT.EVENT_TYPE = 'DEADLOCK'
ORDER BY ACT.EVENT_TIMESTAMP DESC