由于我的 shell 脚本使用超长 SQL 语句多次调用 Db2,我想从脚本中抽象出 SQL 语句并将它们放入一个.sql
文件中,然后从 Db2 命令行处理器运行它db2 -f xxx.sql
。
我希望某些 SQL 语句使用从 shell 脚本传入的变量。
有没有像 Oracle 的方法可以通过'&1'sqlplus
在文件中传递变量?.sql
xxx.sql
SELECT * FROM TABLE_A WHERE FIELD_B > &1
CLP
db2 -f xxx.sql 999
这将返回 DB21004E 错误:
DB21004E You cannot specify both an input file and a command when invoking
the Command Line Processor.