Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Parameters to TD SQL script

Status
Not open for further replies.

swarnapuri

Technical User
Sep 16, 2003
5
0
0
US
Hi,

I am looking for ways to pass variables from Unix shell script to a Teradata SQl script run it using BTEQ. Please let me know how to do this.

It is similar to passing variable to Oracle SQL script and referencing it with &1 etc while running it to Oracle SQL PLUS.

Thanks in advance!

-Vinod
 

myscript copid user password

where myscript looks like....


#! /bin/csh

bteq << EOF

.set sessions 1

.logon $1/$2,$3

.
.
.

.quit
.logoff

EOF


 
Hi,

I should have been more clear in my question. The above solution requires the SQL script to be embedded in the Unix Shell Script. Can we do the same by calling a separate TD SQL script from a Unix Shell Script.

For example, for running Oracle scripts we use

SQLPLUS / @script_name parameter1 parameter2

and the we can reference the paramerters as &parameter1, &parameter2 in the SQL script.

Regards,
Vinod Swarnapuri
 
Hi,
You can define variables in your shell script or in shell script's environment file. If you export these variable and call BTEQ script, it will be automatically used.
e.g. shell script. test_script.sh as below
#---------------
#!/bin/ksh
USER=mydbc/myname
PASS=mypasswd
DATABASE=TEST_DB
MYTABLE=TEST_TABLE
export USER PASS DATABASE MYTABLE

# calling BTEQ script
sh ./mybteq.sql
rt_code=$?
exit 1
================================

# BTEQ script mybteq.sql
bteq << EOF
.logon $USER,$PASS
.database $DATABASE
SELECT * from $MYTABLE;
.quit
.logff
EOF
============================

-- Shrinivas Sagare
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top