Start of change

MESSAGE_QUEUE_INFO table function

The MESSAGE_QUEUE_INFO table function returns one row for each message in a specific message queue. It returns information similar to what is returned by the Display Messages (DSPMSG) CL command and the Receive Nonprogram Message (QMHRCVM) and Open List of Messages (QGYOLMSG) APIs.

This table function does not change the contents of the message queue. The message is kept in the message queue without changing its new or old designation.

Authorization: The user must have *USE authority to the message queue and *EXECUTE authority to the message queue library.

Read syntax diagramSkip visual syntax diagramMESSAGE_QUEUE_INFO(QUEUE_LIBRARY => message-queue-library,QUEUE_NAME => message-queue-name,MESSAGE_FILTER => message-filter,SEVERITY_FILTER => severity-filter)
The schema is QSYS2.
message-queue-library
A character or graphic string expression that contains the name of the library containing message-queue-name. If omitted, the default is QSYS.
message-queue-name
A character or graphic string expression that contains the name of a message queue. If omitted, the default is QSYSOPR.
message-filter
A character or graphic string expression that indicates the type of messages to be returned. The string can contain one or more of the following values separated by blanks. Specifying 'COMPLETE INQUIRY SENDER' is the same as specifying ALL.
ALL
All messages are returned. This is the default.
COMPLETE
Only messages that do not require a reply are returned.
INQUIRY
Only inquiry messages that require a reply are returned.
SENDER
Only copies of the inquiry messages that were sent to other message queues and still require a reply are returned.
severity-filter
An integer value indicating the minimum severity of messages to be returned. The value must be from 0 to 99. The default is 0, indicating all messages are to be returned.

The result of the function is a table containing multiple rows with the format shown in the following table. All the columns are nullable.

Table 1. MESSAGE_QUEUE_INFO table function
Column Name Data Type Description
MESSAGE_ID VARCHAR(7) The message ID for this message.

Contains the null value if this is an impromptu message or MESSAGE_TYPE is REPLY.

MESSAGE_TYPE VARCHAR(13) Type of message. Values are:
  • COMPLETION
  • DIAGNOSTIC
  • ESCAPE
  • INFORMATIONAL
  • INQUIRY
  • NOTIFY
  • REPLY
  • REQUEST
  • SENDER
MESSAGE_SUBTYPE VARCHAR(22) Subtype of message.

The values returned for REPLY messages:

  • FROM EXIT PROGRAM
  • FROM SYSTEM REPLY LIST
  • MESSAGE DEFAULT USED
  • NOT VALIDITY CHECKED
  • SYSTEM DEFAULT USED
  • VALIDITY CHECKED

The value returned for some REQUEST messages:

  • WITH PROMPTING

Contains the null value for other message types.

MESSAGE_TEXT VARGRAPHIC(1024) CCSID 1200 The first level text of the message including tokens, or the impromptu message text.

Contains the null value if MESSAGE_TYPE is REPLY or if the message file could not be accessed.

SEVERITY SMALLINT The severity assigned to the message.
MESSAGE_TIMESTAMP TIMESTAMP The timestamp when the message was sent.
MESSAGE_KEY BINARY(4) The key assigned to the message.

The key is assigned by the command or API that sends the message. For details, see Message Types and Message Keys in the Qmhrcvm API

ASSOCIATED_MESSAGE_KEY BINARY(4) For MESSAGE_TYPE of REPLY, contains the associated inquiry or notify message key.

Contains the null value for other message types.

FROM_USER VARCHAR(10) The current user of the thread when the message was sent.
FROM_JOB VARCHAR(28) The qualified job name of the job that sent the message.
FROM_PROGRAM VARCHAR(10) The program that sent the message.
MESSAGE_FILE_LIBRARY VARCHAR(10) The name of the library containing the message file.

Contains the null value if MESSAGE_ID is null or if the message file could not be accessed.

MESSAGE_FILE_NAME VARCHAR(10) The message file containing the message.

Contains the null value if MESSAGE_ID is null.

MESSAGE_TOKENS VARCHAR(4096) FOR BIT DATA The message token string. If the value is longer than 4096 characters, it will be truncated with no warning.

Contains the null value if there are no tokens.

MESSAGE_SECOND_LEVEL_TEXT VARGRAPHIC(4096) CCSID 1200 The second level text of the message including tokens.

Contains the null value if MESSAGE_ID is null or if the message has no second level text or if the message file could not be accessed.

Example

  • Return a list of inquiry messages in QSYSOPR that have not been replied to
    SELECT MESSAGE_ID, MESSAGE_TEXT, MESSAGE_TIMESTAMP
      FROM TABLE(QSYS2.MESSAGE_QUEUE_INFO(MESSAGE_FILTER => 'INQUIRY'));
End of change