问题描述
您好,我正在尝试将varrays从PHP传递给Oracle.我正在使用OCI8,并且较早地使用varray作为存储过程中的参数,并且在编译时会创建这些varray的类型.因此,在PHP端制作集合实例时,我们可以直接提及集合名称.
Hello I am trying to pass in varrays from PHP to Oracle. I am using OCI8 and have earlier worked with varrays as arguments in stored procedures, and on compilation the types of those varrays are created. So while making collection instance on the PHP end, we can directly mention the collection name.
例如:
$my_coll = oci_new_collection($c, 'MY_ARRAY');
其中MY_ARRAY将是我在Oracle实例中声明的varray类型.
where MY_ARRAY would be the varray type I had declared in the Oracle instance.
create or replace type MY_ARRAY as varray(100) of varchar2(20);
因此,当我在程序包外部创建它们时,该类型将被编译并在执行期间准备就绪.
So when I create them outside a package, the type is compiled and would be ready during execution.
如果我从包裹中这样做,我会找回错误信息
If I do that from packages, I am getting back the error
PHP警告:oci_new_collection()[function.oci-new-collection]:OCI-22303:键入".找不到
我的包裹标题看起来像这样
My package header would look like this
create or replace
PACKAGE my_pack
AS
TYPE my_array_type is VARRAY(200) of varchar2(20);
my_arr my_array_type;
function my_func(
in_id number,
in_arr my_array_type
)
return number;
end my_pack;
现在,当我从PHP进行调用以创建collection的实例时,这就是我的方法
Now when I make a call from PHP to create an instance of collection, this is the way I do
$my_collection = oci_new_collection($connect,'my_pack.my_array_type');
现在我找不到警告类型.
Now I get the warning type not found.
我的问题是,我将如何调用包装中的varray类型???我将其作为package.type_name进行,但是我得到警告,提示找不到类型.
My question is, how would I have to call the varray type that is in the package??? I am doing it as package.type_name, but I am getting the warning that says type not found.
推荐答案
尝试以大写形式传递模式和类型名
Try to pass schema and typename in uppercase
oci_new_collection($connect,'MY_PACK.MY_ARRAY_TYPE', 'MY_SCHEMA')
更新.
我在OCI参考中没有发现任何限制,但是PL \ SQL参考提供了更多信息:
I've found no limitations in OCI Reference, but PL\SQL Reference was more informative:
同样从PL \ SQL参考(表5-1)中,各种集合都有限制.例如在包级别声明的VARRAY:
Also from PL\SQL Reference (Table 5-1) all sorts of collections have restrictions. For example VARRAY declared at package level:
这篇关于使用oci_new_collection访问包内定义的varray类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!