PLS-00306: wrong number or types of arguments in call to 'select_s'

耗尽温柔 提交于 2019-12-04 06:37:33

问题


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

回答1:


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.



来源:https://stackoverflow.com/questions/29637184/pls-00306-wrong-number-or-types-of-arguments-in-call-to-select-s

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!