1
INTRODUCTION
DBMS stands for Database Management System. We can break it like this DBMS=Database
+Management System. Database is a collection of data and Management System is a set of
programs to store and retrieve those data. Based on this we can define DBMS like this:
DBMS is a collection of inter-related data and set of programs to store and access those data
in an easy and effective manner.
Database system are basically developed for large amount of data. When dealing with huge
amount of data, there are two things that require optimization: Storage of data and retrieval of
data. According to the principles of database systems, the data is stored in such a way that it
acquires a lot less space as the redundant data(duplicate data)has been removed before
storage.
Along with storing the data in an optimized and systematic manner, It is also important that
we retrieve the data quickly when needed. Database system ensures that data is retrieved as
quickly as possible.
2
What is Oracle Database?
Oracle database is a relational database management system. It is also called OracleDB, or
simply Oracle. It is produced and marketed by Oracle Corporation. It was created
in 1977 by Lawrence Ellison and other engineers. It is one of the most popular relational
database engines in the IT market for storing, organizing, and retrieving data.
Oracle database was the first DB that designed for enterprise grid computing and data
warehousing. Enterprise grid computing provides the most flexible and cost-effective way to
manage information and applications. It uses SQL queries as a language for interacting with
the database.
3
CASE Statements
The CASE statement in pl/sql is similar to the IF-ELSEIF condition, where different
conditions are listed within a block, and only that statements get executed for which it
satisfies the condition. CASE statement matches the expression value instead of a Boolean
expression. The expression could be of any data type, and the same data type has to be used
in the statements. Each statement has a predefined value, and if that value matches up with
the values passed in the selector expression, then that particular statement gets executed.
CASE statement’s syntax.
CASE (expression)
WHEN <value_l> THEN statement_l;
WHEN <value_2> THEN statement_2;
WHEN <value_3> THEN statement_3;
ELSE default_statement;
END CASE;
Code Explanation
In the syntax above, the expression will return a value of any data type; all the statements will
have a predefined unique value, the CASE expression will go through all the statements until
it gets the exact match defined in the value expression, in this case, Value_1, Value_2, and
Value_3. If the Case expression didn’t find the match in the statement, then the default
statement will get executed.
Note that the ELSE block is optional, and if you do not want any default statement to get
executed, you can skip this statement. The END Case is a mandatory part of the case.
4
Flow Chart
Simple Case Statement
A statement gets executed in the simple case statement if the expression value
matches up with the stated condition. These statement conditions are predefined
while writing the CASE statement. Once the compiler finds a match, it breaks and
comes out of the loop after executing the statement avoiding further unnecessary
5
expression evaluation. If the compiler did not find any match, it would execute the
statement of the default case. The default case is not mandatory and can be skipped.
Syntax
CASE expression
WHEN condition_1 THEN
statements1
WHEN condition_2 THEN
statements2
...
ELSE
statements_else
END CASE;
Explanation
As mentioned earlier, the ELSE case is optional. The compiler first evaluates the
CASE expression; then, it compares the expression with the first condition. If the
condition matches up with the expression statement, 1 will get executed; otherwise,
condition 2 is checked and so forth.
6
IMPLIMENTATION
In this project, we will discuss how we wrote a calculator program in the PL/SQL
programming language. A Calculator is a small electronic device used to perform various
arithmetic operations like addition, subtraction, multiplication, division, percentage, etc. It
makes our calculations easier and faster. It is a portable device that can use anywhere to
perform simple mathematical operations. We use a scientific or sophisticated calculator in
some situations, where we need to solve complex calculations like trigonometry functions,
exponential operators, degrees, radians, log functions, hyperbolic functions etc. Let's discuss
the various ways to create a calculator program in the PL/SQL.
7
Source Code
set serveroutput on
declare
n1 varchar2(200);
n2 varchar2(200);
c varchar2(200);
a_o varchar2(200);
begin
n1:='&n1';
n2:='&n2';
a_o:='&operation';
case(a_o)
when '+' then
c:=n1+n2;
dbms_output.put_line('Addition='||c);
when '-' then
c:=n1-n2;
dbms_output.put_line('subtraction='||c);
when '*' then
c:=n1*n2;
dbms_output.put_line('multiplication='||c);
when '/' then
8
c:=n1/n2;
dbms_output.put_line('division='||c);
when 'pow' then
c:=power(n1,n2);
dbms_output.put_line('Power='||c);
end case;
end;
Output
9
CONCLUSION
This project is one of the sample project on PL/SQL. Though many difficulties were
faced during the project as well as many errors occurred, we became succeed to
com- pile and run the program.
From this very project we were able to achieve various knowledge in PL/SQL
programming and also in logical coding. We refresh our knowledge in DBMS.
Moreover we also gained an experience of group work, team coordination. We
learned how team work is very much important in engineering field.
10