Output to Input Procedure - Basic Teradata Query

Basic Teradata Query Reference

Product
Basic Teradata Query
Release Number
15.00
Language
English (United States)
Last Update
2018-09-25
dita:id
B035-2414
lifecycle
previous
Product Category
Teradata Tools and Utilities

Output to Input Procedure

Use the following steps to resubmit output as input:

1 Use the BTEQ EXPORT command to specify the export file.

2 Use SQL SELECT statements to retrieve data from the Teradata Database.

3 Use the RESET option of the BTEQ EXPORT command to close the export file.

4 Use the BTEQ IMPORT command to specify the file as an import file, using the same format specification used for the EXPORT command in step 1.

5 Use SQL statements with USING modifiers to resubmit the output data as input.

Specifying the Export File

Use the BTEQ EXPORT command to specify the export file. Be sure to specify a format for the export file that is compatible with the subsequent IMPORT command. The EXPORT command automatically sets the BTEQ RECORDMODE command options to the correct values.

Specifying REPORT Format

If REPORT format is specified for the EXPORT command, set the BTEQ FORMAT command option to OFF before entering the SQL SELECT statements. This makes it easier to manually reformat the file later.

Notice:

In REPORT format, BTEQ uses Field Mode to return all data values, including numeric data, in character format. Un-intended results might occur with numeric data fields when this data is re-imported.

Retrieving Data from a Teradata Database

Use SQL SELECT statements to retrieve data from a Teradata Database. Each Teradata SQL SELECT statement retrieves information for one set of results. Use the BTEQ REPEAT or = command when exporting more than a few records from the Teradata Database.

Retrieving Data in REPORT Format

When requesting data in REPORT format, BTEQ performs the following tasks:

  • Retrieves both result values and result labels (column titles, etc.)
  • Organizes the information into a table
  • Writes the table to the export file, including all labels, using one record (row) for each line.
  • Closing the Export File

    Use the RESET option of the BTEQ EXPORT command to close the export file.

    If the REPORT format is specified for the export file, it might be helpful to use a system editor to delete all page headers and footers and column heading from the file.

    Note: Editing a file at this point is helpful, but not necessary. The format statement can be skipped when importing the file back to the Teradata Database.

    Specifying the Import File

    Use the BTEQ IMPORT command to specify the file as an import file, using the same format specification used for the EXPORT command in step 1.

    Resubmitting the Output Data

    Use SQL statements with USING modifiers to resubmit the output data as input. Use the BTEQ REPEAT or = command when importing more than a few records to a Teradata Database.