在 select 语句中使用 varray 类型
Using an varray type in a select statement
我正在尝试在 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 将某些东西放入变量中我想要一个等价物:
select * from STATISTIK where abschluss1 in (10,12);
但是 (10,12) 被一个数组 (varray) 代替了。
是否可以转换 varray 以在 select 语句中使用?
可以,但你的类型必须是全局的
create type array_t is varray(2) of int;
然后用array作为table(open p for只用于编译)
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;
我正在尝试在 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 将某些东西放入变量中我想要一个等价物:
select * from STATISTIK where abschluss1 in (10,12);
但是 (10,12) 被一个数组 (varray) 代替了。
是否可以转换 varray 以在 select 语句中使用?
可以,但你的类型必须是全局的
create type array_t is varray(2) of int;
然后用array作为table(open p for只用于编译)
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;