The difference is that the subroutine headers have formal parameters, which are replaced by the actual parameters when the subroutine is called:
create or replace function f( p_x in varchar2 ,p_y in varchar2 ) return varchar2 is begin return p_x || p_y; end; declare v_z varchar2(10); v_x constant varchar2(1) := 'X'; begin v_z := f(v_x, 'Y'); end;
The formal parameter is not limited (but limited subtypes can be used) and also includes information about the parameter mode and the possible default value, which are not relevant when declaring a variable.
The types of formal and actual parameters should not be the same, but compatible.
There are many other details, but you can read them from the PL / SQL subroutine chapter of the PL / SQL Language Reference . See Section Subroutine Parameters.
I don’t know why formal parameters should be unconditional, but I am very pleased that it removes (unnecessary) data from the subroutine header, making it more abstract.
user272735
source share