Wrong number or types of arguments error while calling procedure

a 夏天 提交于 2019-12-13 04:22:04

问题


How can i call procedure inside another procedure in Oracle?I'm trying as follow but i am getting that error "PLS-00306 (325: 13): PLS-00306: wrong number or types of arguments in call to 'TITLE_CRUD'"

PROCEDURE create_title(
        P_TITLE varchar2,
        P_USER varchar2,
        P_ERR OUT VARCHAR2 
   )
   IS    
   BEGIN  
        IF P_TITLE IS NULL THEN
            P_ERR := 'Null value';
        ELSE
            title_crud('I',NULL,P_TITLE,P_USER);      
        END IF;  
   END;


 PROCEDURE title_crud(
        P_OP_TYPE VARCHAR2,
        P_ID number,
        P_TITLE varchar2,
        P_USER varchar2,
        P_ERR OUT VARCHAR2 
   )...

回答1:


See the change below, the call to title_crud doesn't have a variable to hold what is being returned by it (p_err)

PROCEDURE create_title(
        P_TITLE varchar2,
        P_USER varchar2,
        P_ERR OUT VARCHAR2 
   )
   IS    
   BEGIN  
        IF P_TITLE IS NULL THEN
            P_ERR := 'Null value';
        ELSE
            title_crud('I',NULL,P_TITLE,P_USER,P_ERR); -- Extra Parameter      
        END IF;  
   END;


 PROCEDURE title_crud(
        P_OP_TYPE VARCHAR2,
        P_ID number,
        P_TITLE varchar2,
        P_USER varchar2,
        P_ERR OUT VARCHAR2 
   )...

An easy mistake to make but I find easier to avoid when calling a procedure you pass parameters by named notation. Your call to title_crud becomes

...
 title_crud(P_OP_TYPE => 'I',
            P_ID      =>  NULL,
            P_TITLE   =>  P_TITLE,
            P_USER    =>  P_USER,
            P_ERR     =>  P_ERR);
...


来源:https://stackoverflow.com/questions/22449128/wrong-number-or-types-of-arguments-error-while-calling-procedure

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