0% found this document useful (0 votes)
19 views2 pages

DBMS Practical 5

Uploaded by

janhaviraikar007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views2 pages

DBMS Practical 5

Uploaded by

janhaviraikar007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Zeal College of Engineering and Research

Subject: Database Management System Lab

Name: Janhavi Rahul Raikar


Roll No: T213011
Div: C
Batch: C1
Group A: Practical No. 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:

d-comp-dbms-17@dcompdbms17-OptiPlex-3070:~$ sudo mysql


[sudo] password for d-comp-dbms-17:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.39-0ubuntu0.20.04.1 (Ubuntu)

Copyright (c) 2000, 2024, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its


affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use studcourse;


Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql> desc areas;


+-------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------------+------+-----+---------+-------+
| r | decimal(2,0) | YES | | NULL | |
| area | decimal(10,2) | YES | | NULL | |
+-------+---------------+------+-----+---------+-------+
2 rows in set (0.00 sec)

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)

mysql> select *from areas;


+------+--------+
| r | area |
+------+--------+
| 5 | 78.50 |
| 6 | 113.04 |
| 7 | 153.86 |
| 8 | 200.96 |
| 9 | 254.34 |
+------+--------+
5 rows in set (0.00 sec)

OUTPUT:

You might also like