MySQL Area

This example illustrates how to find the area of rectangle in MySQL. In this example we create a procedure to find the area of rectangle.

MySQL Area

     

This example illustrates how to find the area of rectangle in MySQL.

In this example we create a procedure to find the area of rectangle. In the query below we take two double type variable l and b to be used as input to the procedure and one variable "a" to be used as an output from the procedure. Create the procedure and call it by providing appropriate parameters to display the area of the rectangle.

 

 

 

 

Create Stored Procedure:

Query

 

delimiter //
create procedure rect_area (in l double, in b double, out a double)
begin
set a = l * b;
end
//
delimiter ;

Run Procedure to calculate area: You can run MySQL stored procedure by using the call method.

Query
call rect_area(10, 20, @a);
select @a;
Output
@a
---
200