我想通过一个参数传递多个值。
select
id,
item_number
from AGILE.item_p2p3_query where subclass='2477110' and date32 is not null
and item_number in : p **// passing one parameter would work. But when I pass two parameters like EN 60439-1:1999,EN 60439-3:1991 doesn't seem to work**
--in ('EN 60439-3:1991','EN 60439-1:1999') // this will work
请建议只提出SQL建议而不是PL / SQL,因为我会在报告中使用它。
答案 0 :(得分:2)
我假设您将值绑定到查询,因为它在有一个值时有效,但在有两个值时失败。这就是我如何绑定变量列表中的问题。有一些解决方案,但我喜欢的,不涉及PLSQL的是:
with id_generator
as
(
SELECT regexp_substr(:txt, '[^,]+', 1, LEVEL) token
FROM dual
CONNECT BY LEVEL <= length(:txt) - length(REPLACE(:txt, ',', '')) + 1
)
select u.id, u.username
from users u, id_generator g
where u.id = g.token;
将逗号分隔的字符串绑定为:txt的值,然后将查询结构化为连接。
完整解释 - http://betteratoracle.com/posts/20-how-do-i-bind-a-variable-in-list
答案 1 :(得分:0)
这可能有所帮助 - 任何有效的deptnos lk 10,20 ......列表:
Select * From scott.emp
Where deptno IN (&deptno)
/
如果传递字符串,则使用引号... IN('&amp; ename') 感谢。