在包之间传递关联数组作为参数 [英] Passing an associative array as a parameter between packages

查看:77
本文介绍了在包之间传递关联数组作为参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个单独的Oracle(v9.2)PL/SQL程序包,我正在尝试从package1中的过程传递一个关联数组(即按表索引),作为该过程中参数的参数包装2.这可能吗?编译package1时,我总是得到PLS-00306: wrong number or types of arguments in call to 'ROLLUP_TO_15'.

I've got two separate Oracle (v9.2) PL/SQL packages and I'm trying to pass an associative array (ie, index-by table) from a procedure in package1, as a parameter to a procedure in package2. Is this possible? I keep getting PLS-00306: wrong number or types of arguments in call to 'ROLLUP_TO_15' when I compile package1.

该数组定义为:

type list_tab is table of number(10)
  index by binary_integer;

在两个包装的规格中都是

.在package1的过程中,我将第二个程序包称为package2.rollup_to_15(chanList);.这是我收到编译错误的行(chanList是类型为list_tab的变量).

in both package's spec. In the procedure in package1, I'm calling the second package as package2.rollup_to_15(chanList); That's the line I get the compile error on (chanList is a variable of type list_tab).

在package2中,该过程定义为:

In package2, the procedure is defined as:

procedure rollup_to_15(channels in list_tab) is

我猜我的问题是类型是在每个包中单独定义的,因为我可以将chanList变量传递给第一个包中的其他过程而没有任何问题.

I'm guessing that my problem is that the type is defined separately in each package, because I can pass the `chanList' variable to other procedures within the first package without any problems.

那么,有可能在软件包之间传递一个关联数组吗?如果可以,怎么办?

So, is it possible to pass an associative array between packages? And if so, how?

戴夫

推荐答案

是的,肯定有可能.

很难解释为什么没有包装规格样品时会收到错误,但是通常要传递用户定义的类型作为参数,您应该使用

It's hard to explain why do you receive error without package specs samples, but in general to pass a user-defined type as a parameter you should either with define type DDL, or defining the type in package spec.

我想您要使用后者:)

所以这是一个例子:

create or replace package TestPackage_1
as

type TTestType is table of varchar2(1) index by varchar2(1);

end TestPackage_1;
/

create or replace package TestPackage_2
as

procedure Dummy(aParam TestPackage_1.TTestType);

end TestPackage_2;
/

您可以在任何PL/SQL块中使用TTestType类型,但在SQL中不能.

You can use TTestType type in any PL/SQL block, but not in SQL.

这篇关于在包之间传递关联数组作为参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆