关于oracle储存过程中变量绑定的问题

来源:百度知道 编辑:UC知道 时间:2024/05/28 18:33:51
最近遇到一个问题,在储存过程中有一句
stmt:=select columnA from tableA where id=:1
运行没问题。

把那句变成stmt:select columnA from tablA where id=:1
union
select columnA from tableB where id=:1

报错,no all variables bound. 难道后面那个“:1” 跟前面的不是同一个变量?

像这种一条statement 里面绑定两个同样的变量该怎么办?

涉及到union的语法问题,建议查一下oracle的sql语句语法手册。在网上应该都能找到。
如果union的语法不能这么用,那么用两个单语句来做也能实现同样的功能,分别用一个变量来取得select语句的返回值,然后对这两个变量取“或”,就可以了。

stmt:select columnA from tablA where id=:1
union
select columnA from tableB where id=:1
这句缺少等号
不知是写错了,还是没发现