是否可以在DB2Control center中使用动态SQL或主机变量?

是否可以在DB2Control center中使用动态SQL或主机变量?,db2,Db2,我需要测试一些运行缓慢的准备好的语句 控制中心使用JDBC 在DB2中有CREATEVARIABLE语句。我猜它在服务器上创建了一个变量,而不是一个准备好的语句参数 我需要这样的东西: select * from sysibm.sysdummy1 where 1=?; SQL0313N The number of host variables in the EXECUTE or OPEN statement is not equal to the number of values requir

我需要测试一些运行缓慢的准备好的语句

控制中心使用JDBC

在DB2中有CREATEVARIABLE语句。我猜它在服务器上创建了一个变量,而不是一个准备好的语句参数

我需要这样的东西:

select * from sysibm.sysdummy1 where 1=?;
SQL0313N  The number of host variables in the EXECUTE or OPEN statement is not equal to the number of values required.

select * from sysibm.sysdummy1 where 1=:b1;
SQL0312N  The host variable "b1" is used in a dynamic SQL statement, a view definition, or a trigger definition.

您可以创建bash/batch脚本并从db2clp执行它

db2 connect to mydb
export b1=value
db2 "select * from sysibm.sysdummy1 where 1=$b1"
脚本将替换变量的内容