As my shell script is calling Db2 many times with an ultra long SQL statement, I would like to abstract the SQL statements from the script and put them into a .sql
file, then run it from the Db2 command line processor db2 -f xxx.sql
.
I want some of the SQL statements to use variables that are passed in from the shell script.
Is there any method like Oracle's sqlplus
that can pass variables inside the .sql
file by '&1'?
xxx.sql
SELECT * FROM TABLE_A WHERE FIELD_B > &1
CLP
db2 -f xxx.sql 999
This returns a DB21004E error:
DB21004E You cannot specify both an input file and a command when invoking
the Command Line Processor.