Passing Date parm in Bteq

Database
Fan

Passing Date parm in Bteq

Hi,
I am creating a script where I am defining various date variables then calling another script with those variables so that the query has 'hard coded' date values.

How do I get it to put quotes round the dates? Should it be in the SQL where I define the value, the UNIX file where I assign the variable, or the SQL script where I am trying to test for the value?

Many thanks for any help.
Chris
1 REPLY
Enthusiast

Re: Passing Date parm in Bteq

You should be able to set it at the parent script or the child script, personally I would prefer the quotes to be applied at the child script.

# parent script (calls child script with required date as a string in double quotes - first argument)

child_script.sh "2007-09-15"

#child_script.sh

# run the bteq using the value passed (first argument), apply single quotes on either ends of the value
bteq <<END

SELECT * FROM TRANSACTIONTBL WHERE TRANS_DATE = DATE '$1';

END