使用 oci_new_collection 访问包内定义的 varray 类型
您好,我正在尝试将变量从 PHP 传递到 Oracle。我正在使用 OCI8,并且之前曾使用变量作为存储过程中的参数,并在编译时创建这些变量的类型。所以在PHP端创建集合实例时,我们可以直接提及集合名称。
例如:
$my_coll = oci_new_collection($c, 'MY_ARRAY');
其中 MY_ARRAY 是我在 Oracle 实例中声明的 varray 类型。
create or replace type MY_ARRAY as varray(100) of varchar2(20);
因此,当我在包外部创建它们时,类型会被编译并在执行期间准备就绪。
如果我从包中执行此操作,则会收到错误
PHP警告:oci_new_collection() [function.oci-new-collection]:OCI-22303:类型“”。“my_pack.my_array_type”未找到
我的包头看起来像这样
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 进行调用以创建集合实例时,这就是我所做的
$my_collection = oci_new_collection($connect,'my_pack.my_array_type');
现在我收到警告类型未找到。
我的问题是,我该如何调用包中的 varray 类型???我将其作为 package.type_name 执行,但收到警告说找不到类型。
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.
Ex:
$my_coll = oci_new_collection($c, 'MY_ARRAY');
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 Warning: oci_new_collection() [function.oci-new-collection]: OCI-22303: type ""."my_pack.my_array_type" not found
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;
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.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试以大写形式传递架构和类型名
Upd。
我发现 OCI Reference 中没有任何限制,但 PL\SQL Reference 提供了更多信息:
同样来自 PL\SQL Reference(表 5-1),所有类型的集合都有限制。例如在包级别声明的 VARRAY:
Try to pass schema and typename in uppercase
Upd.
I've found no limitations in OCI Reference, but PL\SQL Reference was more informative:
Also from PL\SQL Reference (Table 5-1) all sorts of collections have restrictions. For example VARRAY declared at package level:
这对我有用:
如果您需要:
This works for me:
If you need out: