MySQL Stored procedure to declare two values and perform mathematical operation


Let us first create a stored procedure −

mysql> delimiter //
mysql> create procedure declare_demo_sp()
   begin
   declare Value1 int;
   declare Value2 int;
   set Value1=100;
   set Value2=2000;
   select Value1,Value2,Value1*Value2 as MultiplicationResult;
   end
   //
Query OK, 0 rows affected (0.00 sec)
mysql> delimiter ;

Call a stored procedure using CALL command −

mysql> call declare_demo_sp();

This will produce the following output −

+--------+--------+----------------------+
| Value1 | Value2 | MultiplicationResult |
+--------+--------+----------------------+
|    100 |   2000 |               200000 |
+--------+--------+----------------------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.00 sec)

Updated on: 27-Dec-2019

547 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements