Re: pass parameter in SQL program
Posted in 1995
tangh@cc.memphis.edu wrote:
: I am writing SQL program in Informix running on UNIX. The program needs to
: do the report for each city and each day, and need to run everyday. Right now,
: I have every coded in the program. I want to be able to pass a parameter of
: cityname and date so I don't have to hard code city name and date. Could I do
: it in informix... I couldn't find the reference in the book.
: Thanks, I appreciate the help. tina.
You could either use sed against the .sql file in question to replace a
distinct pattern with your variables, or use environment in the shell
script, and forego having a .sql file at all. I don't have a handy
example of the former (although I could work one up if you ask), but
below is a shell script I use to get info for a specific table without
going into the Dbaccess menu, which is an example of the latter:
#!/bin/sh
# info - list info for tables in $DBNAME
if [ $# = 0 ]
then
echo "usage: $0 table [table ...]"
exit 0
fi
for TABLE in $*
do
echo $TABLE
dbaccess $DBNAME <<!
INFO COLUMNS FOR $TABLE;
INFO INDEXES FOR $TABLE;
!
done
=======================================================================
Dennis J. Pimple dennisp@informix.com Opinions expressed
Senior Consultant -------------------- are mine, and do not
Informix Software Inc Voice: 303-850-0210 necessarily reflect
Denver Colorado USA Fax: 303-779-4025 those of my employer.