0

How to pass multiple parameters to a SQL file using vsql command line option?

The following is working with asingle argument:

/vsql -h${SERVER} -U${USER} -w${PWD} -A -t -P fieldsep=, -f test.sql -v date1="'"${FIRSTDAY}"'" > test.csv

But I also want to pass last date:

/vsql -h${SERVER} -U${USER} -w${PWD} -A -t -P fieldsep=, -f test.sql -v date1="'"${FIRSTDAY}"'" date2="'"${LASTDAY}"'" > test.csv

but this throws an error:

Database "date2='20160131'" does not exist

mustaccio
  • 18,234
  • 16
  • 48
  • 57
ssal
  • 281
  • 4
  • 14

1 Answers1

1

Simply repeat the -v option as many times as needed:

vsql -h${SERVER} -U${USER} -w${PWD} -A -t -P fieldsep=, -f test.sql \
-v date1="'"${FIRSTDAY}"'" -v date2="'"${LASTDAY}"'" > test.csv
mustaccio
  • 18,234
  • 16
  • 48
  • 57