Oracle PL/SQL - Parameter with default value

Introduction

You can have default values for parameters.

To avoid passing parameters that you would like to keep as default, avoid them if these parameters are the last ones.

All five function calls shown in the preceding code are legal.

You can cut as many parameters as you want from the end.

If you don't want to pass any parameters to a function/procedure, you don't need to type the parentheses.

Demo

SQL>
SQL> declare-- from  w  ww .  ja v  a  2  s. co  m
  2        procedure p_print
  3        (i_str1_tx VARCHAR2 :='hello',
  4         i_str2_tx VARCHAR2 :='world',
  5         i_end_tx VARCHAR2  :='!' ) is
  6        begin
  7             DBMS_OUTPUT.put_line(i_str1_tx||','
  8                   ||i_str2_tx||i_end_tx);
  9        end;
 10  begin
 11        p_print('Hi','anybody','...');  -- both parameters
 12        p_print('Hi','people');      -- without the last
 13        p_print('Hi');               -- only the first
 14        p_print();                   -- no parameters
 15        p_print;                     -- no parenthesis
 16  end;
 17  /
Hi,anybody...
Hi,people!
Hi,world!
hello,world!
hello,world!

PL/SQL procedure successfully completed.

Related Topic