PLS-00306:对"select_s"的调用中参数的数量或类型错误 [英] PLS-00306: wrong number or types of arguments in call to 'select_s'

查看:198
本文介绍了PLS-00306:对"select_s"的调用中参数的数量或类型错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只需直接从编辑器(Toad)中调用它即可.不知道为什么要反复检查函数定义和变量类型而得到上述错误.在线上提供的所有信息似乎都是针对存储过程的-我不相信这里会使用

Just calling this directly from the editor (Toad). No idea why getting the above error having checked the function definition and variable types repeatedly. All of the information available online seems to be for stored procedures - which I don't believe are used here

DECLARE
TYPE attrs_type is VARRAY(10) of STRING(10);
l_ldap_host VARCHAR(255) := 'SERVERNAME';
l_ldap_port INT := 389;
l_ldap_user VARCHAR(255) := 'USERNAME';
l_ldap_passwd VARCHAR(255) := 'PASSWORD';
l_ldap_base VARCHAR(255) := 'l=something,dc=something';
l_session DBMS_LDAP.session;
l_retval NUMBER;
l_entry VARCHAR(255);
l_attrs attrs_type;
l_message VARCHAR(255) := null;
l_filter VARCHAR(255) := 'objectclass=*';

BEGIN
l_session := DBMS_LDAP.init(hostname => l_ldap_host,
                             portnum => l_ldap_port);
l_retval := DBMS_LDAP.simple_bind_s(ld => l_session,
                                    dn => l_ldap_user,
                                passwd => l_ldap_passwd);
l_attrs(1) := '*'; -- retrieve all attributes                      
l_retval := DBMS_LDAP.search_s(
                             ld => l_session,
                             base => l_ldap_base,
                             scope => DBMS_LDAP.SCOPE_SUBTREE,
                             filter => l_filter,
                             attrs => l_attrs,
                             attronly => 0,
                             res => l_message);  
DBMS_OUTPUT.put_line(l_message);
-- code to do stuff                   
EXCEPTION
    WHEN OTHERS THEN DBMS_OUTPUT.put_line (SQLERRM);
END

推荐答案

您必须将l_attrs定义为dbms_ldap.string_collection,而不是您自己的类型.即使您的类型以相同的方式定义,也无法与另一个明显相似的类型互换.对于Oracle,您的attrs_typestring_collection相同.因此,您得到的错误-您确实为该参数使用了错误的类型.

You have to define l_attrs as dbms_ldap.string_collection, not your own type. Even if your type is defined in the same way, it will not be interchangeable with another apparently-similar type. To Oracle, your attrs_type is not the same as string_collection. Hence the error you're getting - you are indeed using the wrong type for that argument.

摘自文档:

包装规范中定义的集合类型与相同定义的本地或独立集合类型不兼容.

A collection type defined in a package specification is incompatible with an identically defined local or standalone collection type.

这篇关于PLS-00306:对"select_s"的调用中参数的数量或类型错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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