Actual Parameters Versus Formal Parameters by manish sharma

Actual parameters versus Formal parameters is a concept that often comes in handy while learning Oracle Database. Moreover, the terms Actual parameters and Formal Parameters are not new to the programming world.

If you have ever studied a programming language like Java and Dot Net then you must have come across these terminologies. While doing the PL/SQL Functions and Stored procedure series these were used very widely in my PL/SQL tutorials and thus I have been often asked to explain the difference between them.

This PL/SQL blog will explain to you what are actual and formal parameters. Also, it will list the differences between them.

What are Formal Parameters?

A formal parameter is a parameter which you specify when you define the subroutine or function.  These parameters define the list of possible variables, their positions along with their datatypes. While specifying the formal parameters in the signature of your subroutines you do not assign any value to them except the default values which make a parameter optional.

Example of Formal Parameters

CREATE OR REPLACE FUNCTION circle_area (radius NUMBER)
RETURN NUMBER IS 

This is the header of the PL/SQL Function which we saw in How to Create Functions in Oracle Database. Here the parameter radius NUMBER is the formal parameter.

public static int Circle_area (int radius) { }

And that is the same function signature in Java where also the parameter int radius is a formal parameter.

What are actual parameters?

Actual parameters are the parameters which you specify when you call the subroutine such as Functions or Procedures. These are actually the values you provide to the subroutine when you call them. You can call a subroutine without an actual parameter when the formal parameter has a default value.  

Example of Actual Parameters

BEGIN
  DBMS_OUTPUT.PUT_LINE(circle_area (25));
END;
/

Here in the above PL/SQL anonymous block, we call the function circle_area( ) whose signature we saw above by passing the value 25 against the formal parameter radius NUMBER. This Numeric value 25 is the actual parameter.

Always make sure that the datatype of the value you specified as an actual parameter must match with the data type of the corresponding formal parameter. Also, the value specified as an actual parameter of a function will override the default value of the corresponding formal parameter if it has any.

That’s it about Formal and Actual Parameters. Do share this blog with your friends & help me spread knowledge. Also, make sure to follow me on my Facebook page for more updates on database concepts. Thanks & have a great day!

1 COMMENT