从PLSQL关联数组中选择?

ash*_*ame 7 plsql

使用关联数组时是否可以使用SELECT FROM?我通过.NET应用程序将数组传递给存储过程,并且我希望能够在从另一个表中进行选择时将该数组用作条件.假设我正在向程序传递一系列ID,我希望能够这样做:

select * from table1 where userID in (select column_value from array)

数组的类型在包中定义:

type id_array is type of number index by pls_integer

Jef*_*emp 13

是的,通过使用流水线函数包装数组是可能的.这是关于流水线功能的一个很好的入门:

http://www.oracle-developer.net/display.php?id=429

更新:Oracle 12c现在支持使用TABLE运算符查询关联数组,只要在包规范中声明类型:https://galobalda.wordpress.com/2014/08/02/new-in-oracle-12c-查询-一个相联阵列合PLSQL的程序/

例如

select * from table1
where userID in (select column_value from table(array));
Run Code Online (Sandbox Code Playgroud)


and*_*ndr 2

不,您无法从 PL/SQL 数组中进行选择,因为您在select from语句中使用 SQL,尽管您可以在 SQL 中使用 DB 定义的嵌套表类型。这篇短文可以帮助您入门。

看看这个简单的综合示例:

> create type temp_t as table of int;/   
Type created.
> select 'test' from dual where 1 in (select * from table(temp_t(1,2,3)));

'TES
----
test
Run Code Online (Sandbox Code Playgroud)