DB2 - 如何在 IBM System i Access for Windows GUI 工具中使用参数运行即席选择查询 [英] DB2 - How to run an ad hoc select query with a parameter in IBM System i Access for Windows GUI Tool
问题描述
我想使用我声明的变量在用于 DB2 的 IBM System I Navigator 工具中运行一些特别选择语句.
I would like to run some ad hoc select statements in the IBM System I Navigator tool for DB2 using a variable that I declare.
例如,在 SQL Server 世界中,我可以轻松地在 SQL Server Management Studio 查询窗口中执行此操作,如下所示:
For example, in the SQL Server world I would easily do this in the SQL Server Management Studio query window like so:
DECLARE @VariableName varchar(50);
SET @VariableName = 'blah blah';
select * from TableName where Column = @VariableName;
如何在 IBM System I Navigator 工具中执行类似操作?
How can I do something similar in the IBM System I Navigator tool?
推荐答案
我在搜索同一个问题时遇到了这篇文章.我的同事给出了答案.确实可以在 Navigator 的即席 SQL 语句中声明变量.它是这样完成的:
I ran across this post while searching for the same question. My coworker provided the answer. It is indeed possible to declare variables in an ad hoc SQL statement in Navigator. This is how it is done:
CREATE OR REPLACE VARIABLE variableName VARCHAR(50);
SET variableName = 'blah';
SELECT * FROM table WHERE column = variableName;
DROP VARIABLE variableName;
如果你不删除变量名,它会一直徘徊,直到谁知道什么时候......
If you don't drop the variable name it will hang around until who knows when...
这篇关于DB2 - 如何在 IBM System i Access for Windows GUI 工具中使用参数运行即席选择查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!