Created
August 19, 2011 15:08
-
-
Save neilkod/1157004 to your computer and use it in GitHub Desktop.
bteq question
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
goal is to set an environment variable to the result of a teradata query | |
-bash-3.1$ cat test_bteq.cmd | |
.logon xxx.yyy.zzz.bbb/username,password | |
select count(*) from sql_class.orders; | |
.QUIT | |
I would like to know if its possible to do something like this | |
export ORDERS_COUNT=`cat test_bteq.cmd|bteq` | |
and $ORDERS_COUNT would be the result of select count(*) From sql_class.orders; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In a shell script:
bteq <<EOBTQ
.LOGON xxx.yyy.zzz.bbb/username,password
.SET TITLEDASHES OFF
.OS rm test.exp
.EXPORT REPORT FILE=test.exp
SELECT COUNT(*) (TITLE '')
FROM DBC.DBCInfo;
.EXPORT RESET
.SET TITLEDASHES ON
.QUIT ERRORLEVEL;
EOBTQ
export ORDERS_COUNT=$(cat test.exp)
echo $ORDERS_COUNT
EOF
It's kind of a cheat having to dump the COUNT(*) to a flat file, but I think it is the only way to get BTEQ to interact with the external environment.