passing ksh variable into bteq function?

Tools & Utilities
Enthusiast

passing ksh variable into bteq function?

I'm trying to pass string variables inside a function (the bteq itself does work) but can't seem to get it to work. I try this:

td_instance="one"
user="usr1"
pass="pass1"
schemaName="schemaA"
tblName="tableA"
query="SEL '>'||COUNT(*) FROM $schemaName.$tblName"

query_td() {bteq .LOGON $td_instance/$user,$pass
DATABASE $schemaName;
.set width 1000;
.set titledashes off;
$1;
.LOGOFF;
.QUIT;
.EXIT
}

echo $(query_td << EOF |grep '^>' |sed -e "s/^>//" EOF "$query")

and keep getting this error:

-ksh: .: syntax error: `)' unexpected

can someone help me pass the variables into the bteq function?

Tags (1)
2 REPLIES
Enthusiast

Re: passing ksh variable into bteq function?

no one has done this?

Enthusiast

Re: passing ksh variable into bteq function?

Hi k1ng

I tried this & it worked for me.

Below is my shell script:

#!/bin/ksh
server=localhost
user=raj
pass=raj
qry="SELECT infokey FROM DBC.DBCINFO sample 1;"

chk_bteq(){
bteq << EOF
.logmech LDAP;
.logon $server/$user,$pass;
$1
.LOGOFF;
EOF
}
chk_bteq "$qry"

Thanks

Raj