Académique Documents
Professionnel Documents
Culture Documents
HERE documents are way of providing text input to the STDIN of programs from within
the shell.
myprogram <<-END
put commands/data that myprogram reads from it's input
more commands and data ....
END
( END label tells the shell that the text for the program's STDIN ends here , this should
be the same label given after <<- )
For example, let's say, in normal scenario, you would type the bteq command in in your
UNIX shell prompt like this and type into it's input (bteq's prompt).
$ bteq
logon tdpid/MYUSERID,
Count(*)
-----------
34130
quit
quit
*** You are now logged off from the DBC.
*** Exiting BTEQ...
*** RC (return code) = 0
$
The same can be done via a HERE DOCUMENT to give the input text commands to
bteq directly from the shell
1 of 2 4/14/2011 9:17 AM
Passing Param from Unix to TD - Toolbox for IT Groups http://datawarehouse.ittoolbox.com/groups/technical-functional/teradata-l...
bteq <<-EOF
run file .mylogon;
SELECT COUNT(*) FROM DBC.TABLES;
quit
EOF
Good thing about here documents is that you can use stuff like shell variables in it. say
you wanted to decided which table to query using a shell variable, you can do it like
this.
QRYTBL=DBC.TABLES
bteq <<-EOF
run file .mylogon;
SELECT COUNT(*) FROM ${QRYTBL};
quit
EOF
before passing the here document text to the bteq, shell will expand it to
You can find further info on HERE documents in any Unix shell tutorials/guides.
regards
2 of 2 4/14/2011 9:17 AM