MESSAGE Block

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

%MESSAGE
A keyword for the block that defines a set of return codes, the associated messages, and the actions Net.Data takes when a function call is returned.

return code spec
A positive or negative integer. If the value of the Net.Data RETURN_CODE variable matches the return code spec value, the remaining information in the message statement is used to process the function call. You can also specify messages for return codes not specifically entered in the MESSAGE block.

+DEFAULT
A keyword used to specify a default positive message code. Net.Data uses the information in this message statement to process the function call if RETURN_CODE is greater than zero (0) and an exact match is not specified.

-DEFAULT
A keyword to specify a default negative message code. Net.Data uses the information in this message statement to process the function call if RETURN_CODE is less than zero (0) and an exact match is not specified.

DEFAULT
A keyword to specify the default message code. Net.Data uses the information in this message statement to process the function call, if all of the following conditions are met:
  • If RETURN_CODE is greater or less than zero, but not zero
  • If no exact match for the return code is specified
  • If the +DEFAULT or -DEFAULT values are not specified for when RETURN_CODE is greater or less than zero

msg_code
The message code that specifies errors and warnings that can occur during processing. A string of numeric digits with values from 0 to 9.

SQLSTATE
A keyword that provides application programs with common codes for common error conditions.The SQLSTATE values are based on the SQLSTATE specification contained in the SQL standard, and the coding scheme is the same on all IBM implementations of SQL. This value is matched with the Net.Data variable SQL_STATE.

state_id
The SQLSTATE. An alphamumeric string of five characters (bytes) with a format of ccsss, where cc indicates class and sss indicates subclass.

message text spec
A string that is sent to the Web browser if either the RETURN_CODE matches the return_code value or the SQL_STATE variable matches the SQLSTATE value in the current message statement.

string
Any sequence of alphabetic and numeric characters and punctuation. If the string appears within double quotes, the new-line character is not allowed.

variable reference
Returns the value of a variable and is specified with $ and (). For example: if VAR='abc', then $(VAR) returns the value 'abc'. See Variable Reference for syntax information.

function call
Invokes one or more FUNCTION or MACRO_FUNCTION blocks, or a Net.Data built-in function with specified arguments. See Function Call (@) for syntax and examples.

action spec
Specifies what action Net.Data takes if the RETURN_CODE variable matches the return_code value, or the SQL_STATE variable matches the SQLSTATE value in the current message statement.

EXIT
A keyword that specifies to exit the macro immediately when the error or warning corresponding to the specified message code occurs. This value is the default.

CONTINUE
A keyword that specifies to continue processing when the error or warning corresponding to the specified message code occurs.

include statement
The INCLUDE statement. Reads and incorporates a file into the Net.Data macro. The INCLUDE statement can appear anywhere in the MESSAGE. See INCLUDE Statement for syntax and examples.

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"
 %}                         


[ Top of Page | Previous Page | Next Page | Index ]