Purpose
Specifies messages to display and actions to take based on the return code from a function.
Define the set of return codes, along with their corresponding messages and actions in the MESSAGE block. When a function call completes, Net.Data compares its return code with return codes defined in the MESSAGE block. If the function's return code matches one in the MESSAGE block, Net.Data displays the message and evaluates the action to determine whether to continue processing or exit the Net.Data macro.
A MESSAGE block can be global in scope, or local to a single FUNCTION block. If the MESSAGE block is defined at the outermost macro layer, it is considered global in scope. When multiple global MESSAGE blocks are defined, only the last block processed is considered active. If the MESSAGE block is defined inside a FUNCTION block, the block is local in scope to the FUNCTION block where it is defined. See the MESSAGE block section in the Net.Data Administration and Programming Guide for return code processing rules.
Syntax
>>-%MESSAGE--{--------------------------------------------------> .--------------------------------------------------------------------------------------. V | >--------+--------------------------------------------------------------------------------+--+> '--+-| return code spec |--+--:---| message text spec |----+------------------+--' '-| SQLSTATE |----------' '-| action spec |--' >----%--}------------------------------------------------------>< return code spec |---+-DEFAULT------------+--------------------------------------| +-+DEFAULT-----------+ +- -DEFAULT----------+ +-+----+---msg_code--+ | +- --+ | | '-+--' | '-include statement--' SQLSTATE |---SQLSTATE--:------state_id-----------------------------------| message text spec .--------------------------. V | |----+-"-----+--------------------+--+---"---+------------------| | +-string-------------+ | | +-variable reference-+ | | +-function call------+ | | '-(new_line)---------' | | .--------------------------. | | V | | +-{-----+--------------------+--+---%}--+ | +-string-------------+ | | +-variable reference-+ | | '-function call------' | '-include statement---------------------' action spec .-EXIT-----. |---+-:--+----------+----+--------------------------------------| | '-CONTINUE-' | '-include statement--'
Values
Context
The MESSAGE block can be found in these contexts:
Restrictions
The MESSAGE block can contain these elements:
For OS/390: SQL functions cannot be called from inside SQL functions.
Examples
Example 1: A local MESSAGE block
%{ local message block inside a FUNCTION block %} %FUNCTION(DTW_REXX) my_function() { %EXEC { my_command.cmd %} %MESSAGE{ -601: {<h3>The table has already been created, please go back and enter your name.</h3> <p><a href="input">Return</a> %} default: "<h3>Can't continue because of error $(RETURN_CODE)</h3>"%} : exit %}
Example 2: A global MESSAGE block
%{ global message block %} %MESSAGE { -100 : "Return code -100 message" : exit 100 : "Return code 100 message" : continue +default : { This is a long message that spans more than one line. You can use HTML tags, including links and forms, in this message. %} : continue %} %{ local message block inside a FUNCTION block %} %FUNCTION(DTW_REXX) my_function() { %EXEC { my_command.cmd %} %MESSAGE { -100 : "Return code -100 message" : exit 100 : "Return code 100 message" : continue -default : { This is a long message that spans more than one line. You can use HTML tags, including links and forms, in this message. %} : exit %}
Example 3: A MESSAGE block containing INCLUDE statements.
%message { %include "rc1000.msg" %include "rc2000.msg" %include "defaults.msg" %}