use teradata table field values in shell script?

UDA
Enthusiast

use teradata table field values in shell script?

i have to read some data from a teradata table and use them in my shell script.. how do i do that.. we can use BTEQ .. but i don know how to pass the field values as variables to the shell.. please help me....

imagine the table has four dates in four different formats and i want it in 4 variables with which i could program in my shell script...
4 REPLIES
Enthusiast

Re: use teradata table field values in shell script?

#/bin/ksh
VAR1=tablea
bteq<< EOD

.logon ...

select * from $VAR1;

EOD

Enthusiast

Re: use teradata table field values in shell script?

here if i print only the table name gets printed right... ?.. i want the values of the row..

Enthusiast

Re: use teradata table field values in shell script?

guys can some1 please help on this.. i have'nt got a solution yet.... all i need is to assign the value of the table to a shell variable

for eg

bteq<< EOD
.RUN FILE /home/nbk6cst/dbpass;
select * from load_work.setmonth;
.logoff;
EOD

this is the bteq script and need to assing the values returned by the setmonth table to a unix variable, so that i could use them in my shell..
Enthusiast

Re: use teradata table field values in shell script?

This exports the shell variable DBVAR to the value in colname in load_work.setmonth. it goes into file newvar.sh

bteq<< EOD
.RUN FILE /home/nbk6cst/dbpass;
.os rm newvar.sh
.export report file = newvar.sh
.format off
select 'export DBVAR='||colname (Title '') from load_work.setmonth;
.export reset
.logoff;
EOD

You can then set the variable by:

.newvar.sh

and then call your script which uses the new variables.

You cannot put the script which takes the shell variables in the script which uses them. It you do, the execution of the Korn shell (assuming you use Korn - same for the others) will set up the second script using the variable value before it is extracted - so it will probably be null.

The Unix commands to run the script are:

.setvar # this is the script above
.newvar # the file created by setvar
.usevar # ie the main script which uses the variables and does the real work!

HTH