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

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

问题描述

直接从编辑器 (Toad) 调用它.不知道为什么在反复检查函数定义和变量类型后会出现上述错误.在线提供的所有信息似乎都适用于存储过程 - 我认为这里没有使用这些信息

DECLARETYPE attrs_type 是 STRING(10) 的 VARRAY(10);l_ldap_host VARCHAR(255) := 'SERVERNAME';l_ldap_port INT := 389;l_ldap_user VARCHAR(255) := '用户名';l_ldap_passwd VARCHAR(255) := '密码';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=*';开始l_session := DBMS_LDAP.init(hostname => l_ldap_host,端口号 =>l_ldap_port);l_retval := DBMS_LDAP.simple_bind_s(ld => l_session,dn =>l_ldap_user,密码 =>l_ldap_passwd);l_attrs(1) := '*';-- 检索所有属性l_retval := DBMS_LDAP.search_s(ld =>l_session,基数 =>l_ldap_base,范围 =>DBMS_LDAP.SCOPE_SUBTREE,过滤器 =>l_过滤器,属性 =>l_attrs,attronly =>0,资源=>l_message);DBMS_OUTPUT.put_line(l_message);-- 做事的代码例外WHEN OTHERS THEN DBMS_OUTPUT.put_line (SQLERRM);结尾

解决方案

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

来自文档:><块引用>

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

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

解决方案

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.

From the documentation:

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天全站免登陆