All Forums General
radsubra 33 posts Joined 10/12
15 Sep 2014
Paasing shell script variables in to BTEQ script

Hi,
 
I have shell script which has set of variables which iam reading from a parameter file
 
read CUST_CORE CUST_STG CUST_SAND  < ${WORKDIR}/ida_td_usg_load.prm

export CUST_CORE
export CUST_STAGE
export CUST_SANDBOX
 
I have to write a BTEQ script which I will be passign as a paramter to the above  shell script and I want to use all the above 3 variables in my BTEQ script . What is the best method to achieve this?
Thanks,
Radha
 
 
 
 
 

Raja_KT 1246 posts Joined 07/09
15 Sep 2014

If I understand you correctly, is this waht you mean?:
#!/usr/bin/ksh

export CUST_CORE

export CUST_STAGE

export CUST_SANDBOX

 

 

bteq<<! >>${LOG_FILENAME} 2>&1

 

.logon yourip/username,password

 

<you can use the parameters here>

!

<then unix script again>

Raja K Thaw
My wiki: http://en.wikipedia.org/wiki/User:Kt_raj1
Street Children suffer not by their fault. We can help them if we want.

radsubra 33 posts Joined 10/12
16 Sep 2014

No I have a shell script names execTDSQL.sh  which has the following variables defined
 
read CUST_CORE CUST_STG CUST_SAND  < ${WORKDIR}/ida_td_usg_load.prm export CUST_CORE
export CUST_STAGE
export CUST_SANDBOX
 
I have another BTEQ script  abc.sql I want use the the above variables in the bTEQ script  and pass the bteq script as a first paramter to the shell script and it should be able to replace the variables with the actual database name.
 
sh execTDSQL.sh abc.sql

Raja_KT 1246 posts Joined 07/09
16 Sep 2014

I see your export does not have values.
 Why cant you stuff sql inside the sh, example below:

export DB_NAME=abc

export DB_USER_NAME=def

 

bteq<<! >>$PWD/abf.log 2>&1

 

.logon ${DB_NAME}/${DB_USER_NAME},don't_tell_anyone

.run file $HOME/abc.sql

.quit

!

Raja K Thaw
My wiki: http://en.wikipedia.org/wiki/User:Kt_raj1
Street Children suffer not by their fault. We can help them if we want.

You must sign in to leave a comment.