0

我正在尝试在 select 语句中使用 varray 类型:

CREATE OR REPLACE PROCEDURE ARRAYTEST IS
  type array_t is varray(2) of int;
  array_test array_t := array_t(10,11);
BEGIN
  select * from STATISTIK where abschluss1 in array_test;
END;

但这给了我一个错误:

PLS-00428: an INTO clause is expected in this SELECT statement
PLS-00642: local collection types not allowed in SQL statement

第一个异常似乎具有误导性,我不想在我想要的变量中选择一些东西:

select * from STATISTIK where abschluss1 in (10,12);

但是 (10,12) 被一个数组 (varray) 代替。

是否可以将可变数组转换为在选择语句中使用?

4

1 回答 1

1

这是可能的,但您的类型必须是全局的

create type array_t is varray(2) of int;

然后使用数组作为表(打开 p仅用于编译)

 declare
    array_test array_t := array_t(10,11);
p sys_refcursor;
    begin
open p for
       select * from STATISTIK where abschluss1 in (select column_value from table(array_test ));
    end;
于 2015-07-29T14:44:16.533 回答