DB2 - 如何在IBM System i Access for Windows GUI Tool中运行带有参数的临时选择查询 [英] DB2 - How to run an ad hoc select query with a parameter in IBM System i Access for Windows GUI Tool

查看:142
本文介绍了DB2 - 如何在IBM System i Access for Windows GUI Tool中运行带有参数的临时选择查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用我声明的变量在IBM System I Navigator工具中运行一些特殊的select语句。

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中服务器世界我很容易在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中的ad hoc 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 Tool中运行带有参数的临时选择查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆