问题描述
我已经创建了xyz软件包,如下所示:-
I have created a package xyz like follows :-
create or replace package xyz
is
procedure abc( v_frst_param in VARCHAR2 default 'Y')
IS
BEGIN
dbms_output.put_line(v_frst_param);
-- CALLING another function
update_table(p_frst_parm =>v_frst_param,
p_second_param =>'2');
END;
在dbms_output.put_line中,当我在调用abc过程时未传递任何值时,输出将为null.如果我已通过默认设置,但我没有通过任何参数,则该值不应在输出中为Y
In the dbms_output.put_line the output is coming null when i am not passing any value while calling abc procedure.if i have passed default and i am not passign any parameter shouldnt the value come as Y in the ouput
推荐答案
首先,我认为程序包无效,您正在尝试在程序包规范中为函数添加主体.但是,整个构想是好的,它应该可以正常工作,例如,如果做对了,创建一个包:
First of all, I think that package would be invalid, you are trying to add a body for your function in your package specification. However the whole idea is good and it should be working, if done right, for example, create a package:
create or replace package xyz is
procedure abc(v_frst_param in varchar2 default 'Y');
procedure abc(v_frst_param in varchar2 default 'Y', v_second_param in varchar2);
end xyz;
还有一个包体:
create or replace package body xyz is
procedure abc(v_frst_param in varchar2 default 'Y') is
begin
dbms_output.put_line(v_frst_param);
end;
procedure abc(v_frst_param in varchar2 default 'Y', v_second_param in varchar2) is
begin
dbms_output.put_line(v_frst_param || ' / ' || v_second_param);
end;
end xyz;
然后您可能要调用过程:
Then you may want to make the call of your procedure:
begin
xyz.abc;
xyz.abc(); -- This is the same thing as above
xyz.abc(v_second_param => 'Maybe');
end;
请注意,如果您向该过程发送任何内容作为v_first_parameter的参数,它将使用您发送的值而不是默认值.
Please note that if you send anything as a parameter for v_first_parameter to that procedure, it will use the value you sent and not the default one.
这篇关于oracle过程中的默认参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!