如何使SQL Developer/SQL +仅提示一次在单个语句中多次出现的替换变量? [英] How can I make SQL Developer/SQL+ prompt only once for a substitution variable that occurs multiple times in a single statement?

查看:124
本文介绍了如何使SQL Developer/SQL +仅提示一次在单个语句中多次出现的替换变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大致这样的查询:

I have a query roughly like this:

 select * 
  from A_TABLE 
  where A_COLUMN = '&aVariable'
    union
 select * 
  from A_TABLE 
  where B_COLUMN = '&aVariable';

但是,当我运行它时,即使它是相同的变量,SQL Developer也会提示我两次输入该变量.

But when I run it, SQL Developer prompts me for the variable twice, even though it's the same variable.

如果有一种方法可以使只使用两次的变量仅提示一次,该怎么办?

If there's a way to make it prompt only once for a variable that is used twice, how do I do it?

不想使用脚本,它必须是单个可执行查询.

I do not want to use a script, it must be a single executable query.

推荐答案

在撰写本文时,我想出了如何做:

As I was forming this post, I figured out how to do it:

 :a_var
 select * 
  from A_TABLE 
  where A_COLUMN = :a_var
    union
 select * 
  from A_TABLE 
  where B_COLUMN = :a_var;

然后,SQL Developer将提示您输入绑定变量,您可以输入它并单击Apply.

SQL Developer will then prompt for a bind variable, you can enter it and hit apply.

这篇关于如何使SQL Developer/SQL +仅提示一次在单个语句中多次出现的替换变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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