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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bteq variables

Status
Not open for further replies.

spiers

Programmer
Joined
Apr 1, 2004
Messages
1
Location
GB

Does anyone know how to pass variables from a unix shell script to a Bteq script

I have a shell script that formats a string and then calls a bteq script


Select statment from bteq script


Select * from DECODED_FILE_AUDIT_HISTORY
WHERE filename =$FILENAME
and source='BMD';

.IF ERRORCODE <> 0 THEN .GOTO ERRORFOUND;
/* ----------------------------
-------------------------------- */

The shell script looks like

export FILENAME=TT915647asrtf

cat ~cromcode/sql/.dblogon select_toll_file.sql | bteq >>select_toll_file.log 2>>select_toll_file.log

is this correct??
 
Hi,
I don't think CAT will substitue $FILENAME and I know BTEQ won't.

I guess you could do this in SH/KSH. I am just more comfortable programming in CSH.


Code:
#!/bin/csh

set a = ( `cat ~cromcode/sql/.dblogon` )

set sq = "'";

#file name must be inside single quotes;
set FILENAME = "${sq}${1}${sq}"

bteq << here
$a

Select * from DECODED_FILE_AUDIT_HISTORY
WHERE filename = $FILENAME
and source='BMD';

.IF ERRORCODE <> 0 THEN .GOTO ERRORFOUND;
/* ----------------------------
-------------------------------- */

    .
    .
    .

.label ERRORFOUND

logoff;
quit;

here

then run the script

myscript TT915647asrtf >>select_toll_file.log 2>>select_toll_file.log

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top