如何将NUMBER与“ TYPE IS TABLE OF NUMBER”进行比较?

时间:2019-04-03 20:48:32

标签: sql oracle

我有查询,需要在UPDATE FROM JOIN中选择IDname。首先,我使用函数检查ID。在函数中,我得到几个需要与ID比较的值。当我进行检查时,出现错误:ID

此查询:

ORA-00932: inconsistent datatypes: expected NUMBER got ARRAY

我用于从函数保存值的类型:

select o.id, o.name as value from table1 o, table2 r
where r.id IN (pkg.GET_VALUE(null, 1)) --error in this line
and r.id = o.id

比较 TYPE "ARRAY" as table of number(10) NUMBER有多正确?

2 个答案:

答案 0 :(得分:4)

使用MEMBER OF运算符:

select o.id, o.name as value
from   table1 o
       INNER JOIN table2 r
       ON ( r.id = o.id )
where r.id MEMBER OF pkg.get_value( null, 1 )

(您也可以使用INNER JOIN而不是使用Oracle的旧逗号联接语法)

答案 1 :(得分:1)

如果函数返回,请查看是否有帮助:

select ...
from ...
where r.id in (select * From table(pkg.get_value(null, 1)))    --> this
and r.id = o.id