When to Use a Here Document for Standard Input Files | Basic Teradata Query - Using a Here Document for Standard Input Files - Basic Teradata Query

Basic Teradata® Query Reference - 20.00

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
Lake
VMware
Product
Basic Teradata Query
Release Number
20.00
Published
October 2023
ft:locale
en-US
ft:lastEdition
2025-04-02
dita:mapPath
gxl1691484661681.ditamap
dita:ditavalPath
obe1474387269547.ditaval
dita:id
psp1479308573013
Product Category
Teradata Tools and Utilities

In scenarios where environment variables need to be used as part of the BTEQ script, a Here document, which can be used to specify a string literal in a command-line shell, is a possible option.

The following example outlines a UNIX script as a Here document.

#!/bin/sh
#########################################
export DATADIR=/datasvc/data
bteq <<EOI
.LOGON mydbs/myid,mypw;
.EXPORT REPORT FILE=$DATADIR/output
SELECT * from table_name;
.EXPORT RESET
.LOGOFF
.EXIT
EOI
#########################################