MESSAGEOUT - Basic Teradata Query

Basic Teradata Query Reference

Basic Teradata Query
Release Number
October 2018
English (United States)
Last Update
Product Category
Teradata Tools and Utilities


Specifies the name of a file to which BTEQ is to redirect the contents that would normally get sent to the standard output stream.


The following figures show the syntax for both mainframe-attached and workstation-attached systems.

where the following is true:

The name of the z/OS JCL DD or workstation file name to receive data that is normally sent to the standard output stream.
For workstation-attached systems, determines if a BOM (Byte Order Mark) is inserted at the beginning of a new MESSAGEOUT file for Unicode sessions.

Specifying BOM inserts a UTF-8 or UTF-16 byte order mark, while NOBOM does not. The default is BOM.

This option does not apply if the file already exists and is non-empty. It is not available for non-Unicode sessions or for mainframe-attached systems.

This option does not apply to mainframe-attached systems because standard output is written in EBCDIC for Unicode sessions.

Redirect the standard output back to the original stdout/SYSPRINT stream. This may be a terminal screen, a redirected file, a pipe, or some other device. Upon successful completion, BTEQ closes the previous MESSAGEOUT file.

Usage Notes

If specifying an existing file, BTEQ appends data to that file. Otherwise, a new file is created. Use any device name that is valid on the system as a file name.

BTEQ closes the MESSAGEOUT file when one of the following is executed:
  • A MESSAGEOUT command specifying another message file
  • A MESSAGEOUT command specifying the RESET option
  • An EXIT or QUIT command

BTEQ does not close the file until the last file record is written. If the file is read before it is closed, the last few records might be missing. They are added when the file is closed in response to the MESSAGEOUT, EXIT, or QUIT command.

For workstation-attached systems, when BTEQ is started with the -m command line option, stdio is based on the system locale. Therefore, the MESSAGEOUT file contains locale-specific characters (instead of UTF-8 or UTF-16 encoded characters) and does not contain a BOM.

If a MESSAGEOUT command fails in batch mode, BTEQ will print an error message and terminate. If a MESSAGEOUT command fails during interactive mode, BTEQ will continue to write its standard output to the previous MESSAGEOUT file, if it exists. Otherwise, BTEQ will continue to write to the stdout/SYSPRINT stream.

Example 1 – MESSAGEOUT

For z/OS, to redirect messages to the DDNAME MYOUT use the following command:


Where DDNAME was previously defined with a TSO command. For example:


Example 2 – MESSAGEOUT

From a workstation-attached system, to redirect standard output to the file OUT1, use the following command:

In order to restore standard output back to the stdout stream and close the OUT1 file, use the following command:

Example 3 – MESSAGEOUT

From a workstation-attached system, part of BTEQ's output can be discarded by sending it to /dev/null via the MESSAGEOUT command. Since an import normally generates a few lines of output for each record imported, the result could be a large output file. The standard output can be reduced by redirecting it to /dev/null and then restoring it with the RESET option.

Script commands:
USING c1 (VARCHAR(100)), c2 (VARCHAR(100)), c3 (VARCHAR(100))
INSERT INTO my_table1 VALUES (:c1, :c2, :c3);
SELECT 'Validate Inserts', count(*) from my_table1;
Relevant output:

*** Redirecting output messages to file /dev/null
SELECT 'Validate Inserts', count(*) from my_table1;

*** Query completed. One row found. 2 columns returned.
*** Total elapsed time was 1 second.

'Validate Inserts'     Count(*)
------------------  -----------
 Validate Inserts          53285