【发布时间】:2015-11-25 14:08:07
【问题描述】:
我有一个将数字表作为输入的函数:
function foo(ids in custom_array)...
其中custom_array 是一个数字表。
如果我只需要传递 1 个参数,如何从 SQL 查询中调用此函数?
我想这应该是这样的
select * from table(foo(123))
但我的猜测是错误的。
编辑: 函数的声明如下所示:
create or replace function foo(id in custom_array) return
tableof2numbers AS
mytable tableof2numbers;
BEGIN
SELECT cast(
MULTISET (
/*there goes some super secret business logic*/
/*let's say that here we just do smth like this: */
select 123, 123 from dual
/*because this is not so important for this question*/
)
AS tableof2numbers)
INTO
mytable
FROM dual;
RETURN mytable;
其中tableof2numbers 是另一种自定义类型,其声明与custom_array 非常相似,但有两个数字。
提前致谢!!!
【问题讨论】:
-
我收到这个错误:ORA-06553: PLS-306: wrong number or types of arguments in call to 'foo'
-
请显示 custom_array 类型和 foo 的完整定义。
-
foo返回什么?您的示例调用似乎暗示它返回一个集合。您当然有可能拥有一个将集合作为输入并返回集合作为输出的函数,但也有可能您使用了错误的语法来调用它。参数可能应该是foo(custom_array(123)),但没有足够的信息来了解完整的select语句。 -
@JustinCave 我收回我的评论“不,语法是正确的” - 我把
foo误认为是数字类型表的名称。 -
select * from table(sys.odcinumberlist(1,2,3,4,5,6,7,8)) where column_value