The MsgKeys table can run into problems when deleting from two types of triggers. The first type will be caused by the MsgTbl table. The second caused by the DescRec table.
It is assumed you wish to remove a message completely and are not attempting to rename a message list. To handle the MsgTbl, simply perform a delete statement on the table name in the MsgTbl table. For example, one might have created a UserSR message for a custom status read that is no longer used. In this case, the following should be done.
sample1=>
DELETE FROM MsgTbl WHERE MGown='UserSR';
DELETE 2
sample1=>
DELETE FROM MsgKeys WHERE MsgNme='UserSR';
DELETE 1
The message list may still be in use by a DescRec entry, preventing deletion. If the DescRec entry is no longer needed, delete it. Otherwise, use the fetch and update commands to point the record to a different message list.