DBMS Practical 5
DBMS Practical 5
PROBLEM STATEMENT:
Write a PL/SQL code block to calculate the area of a circle for a value of radius varying from 5 to 9.
Store the radius and the corresponding values of calculated area in an empty table named areas,
consisting of two columns, radius and area.
CODE:
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
Database changed
mysql> delimiter //
mysql> create procedure proc()
-> begin
-> declare r decimal(2,0) ;
-> declare pi decimal(4,2);
-> declare area decimal(10,2);
-> set r=5.0;
-> set pi=3.14;
-> while(r<=9) do
-> set area = pi*power(r,2);
-> insert into areas(r,area) values(r,area);
-> set r=r+1;
-> end while;
-> end //
Query OK, 0 rows affected (0.11 sec)
mysql> delimiter ;
mysql> call proc();
Query OK, 1 row affected (0.51 sec)
OUTPUT: