Getting bteq to just return the result

UDA
Fan

Getting bteq to just return the result

Hi,

I'm new to Teradata. Extensive experience with UDB. I'm trying to convert some KSH scripts that we use for job control to hit a TD DB instead of a UDB DB. The problem I'm having is all the extra stuff that comes back with a bteq result set.

With udb I can assign a variable like this

var1="db2 -x 'select distinct field1 from table1'"

That statement will return just field1 and assign the value to var1.

I can't do that with bteq. I have to create an sql file that exports field1 to another file that I then cat into the variable. There has to be a more graceful way!

Help!

Thanks,
DOZA
2 REPLIES
Enthusiast

Re: Getting bteq to just return the result

Hi

TD no can do, unless you write a program ...
Teradata Employee

Re: Getting bteq to just return the result

Like the man said no can do, but here's one option you might try. Granted this is a hack but it avoids exporting. The perl ditty reads the stdout and prints just the value after the pattern you put in the output. This website clobbers the two < signs so replace the > with <.

#!/usr/bin/ksh

#replace > with < cuz teradata.com is clobbering it

bteq>>EOF | perl -ne '/this_is_the_data(.*)/ && print "$1\n"' | read MYVAR

.logon whatever;

select 'this_is_the_data' || trim(my_foo_column) (title '') from my_foo_table;

.quit
EOF

echo $MYVAR