How to connect to TeraData in SHell Script

Connectivity

How to connect to TeraData in SHell Script

Hi Teame

I am new to teradata, I haved DB2, in which for connection to DB is quite easy, just call profile and connect to db and we can use UNIX command after SQL if need to do with that.

I have searched abt TeraData, but didn't find the solution , Here we need to call BTEQ which is not supported UNIX command, for each SQL we need to use export in temp files if want to do any calculation on it. If there is any other way to do it, Please share...

One more thing, I have tried to write a small script , But this is giving error :

cat teraconchk.sh

echo "This script will connect to teradata and fetch the data"

`bteq<<EOC

.logon test/sysdba,pass

select * from dbc.tables;

.logoff

EOC

`

echo "Done"

Error:

./teraconchk.sh

This script will connect to teradata and fetch the data

 *** Warning: EOF on INPUT stream.

./teraconchk.sh: line 9: BTEQ: command not found

Done

Please help

DataStage4you

http://datastage4you.blogspot.in/

Tags (2)
3 REPLIES

Re: How to connect to TeraData in SHell Script

Try to add semicolon after password.

Below my script shell example

#!/bin/sh

LE=$1

bteq <<EOI

#.LOGMECH LDAP;

#.LOGON unicred1/ee29770,dpndnl79$$;

.LOGON unicred1/etlcostd,etlcostd;

.SET WIDTH 200;

SELECT COMPANY_CD

FROM

D_DCOST_PRIMARY.T0059_LEGAL_ENTITY

WHERE

LEGAL_ENTITY_CD = '$LE';

.LOGOFF;

.EXIT;

EOI

Re: How to connect to TeraData in SHell Script

Hi,

I am newdie to shell scripting, Please suggest for my issue.

When I try this code in shell script, I am getting the error ".LOGON: command not found".

I executed the simple sql script in shell but its showing the below errors

 ".LOGON: command not found"

 ".LOGOFF: command not found"

N/A

Re: How to connect to TeraData in SHell Script

saranya,

you need bteq to log in using bteq

/usr/bin/bteq << EOF >> LOG 2 >> LOG

.LOGON host/user ,pass;

.LOGOFF

EOF

should be saranya and  datastage4you solve with that step.