100% found this document useful (1 vote)
3K views18 pages

PL/SQL Control Structures Project Report

This document summarizes a student project on executing PL/SQL programs using different conditional statements like if-else and for/while loops. The project was completed by three students under the guidance of their teacher, Mr. Kazi A.D. The project aimed to help students understand how to retrieve needed information from a database table based on specified conditions using PL/SQL conditional statements. It describes the various control structures used in PL/SQL like if-then statements and case statements to test conditions.
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
100% found this document useful (1 vote)
3K views18 pages

PL/SQL Control Structures Project Report

This document summarizes a student project on executing PL/SQL programs using different conditional statements like if-else and for/while loops. The project was completed by three students under the guidance of their teacher, Mr. Kazi A.D. The project aimed to help students understand how to retrieve needed information from a database table based on specified conditions using PL/SQL conditional statements. It describes the various control structures used in PL/SQL like if-then statements and case statements to test conditions.
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
  • Brief Introduction
  • Aim of the Microproject
  • Action Plan
  • Resources Required
  • Brief Description
  • Aim of Microproject
  • Actual Producar followed
  • Acknowledgement
  • Reference

COMPUTER ENGINEERING DATABASE MANAGEMENT SYSTEM

Maharashtra State Board of Technical Education,


Mumbai

Vidyavardhini Charitable Trust’s

Abhaysinhraje Bhonsle Institute of Technology


Shahunagar - Shendre, Satara.

2020-2021

A PROJECT REPORT ON

Project Name: “Execute PL/SQL Program using different conditional statement


(if else, for /while)”

SUBMITED BY:

1) PATIL SHUBHAM NANASO (16)


2) PAWAR TEJAS GOPAL (17)
3) SAWALE KARAN YUVRAJ (18)

UNDER THE GUIDANCE OF: Mr. Kazi. A.D

Sub Teacher Name: Mr. Kazi. A.D

(Computer Dept.)
CERTIFICATE:
Page 1 of 18
COMPUTER ENGINEERING DATABASE MANAGEMENT SYSTEM

This is to certify that:

▪ Roll No: 16
▪ Roll No: 17
▪ Roll No: 18

Diploma in Computer Engineering, has satisfactorily completed the project work under
mini project report on, Project Name: “Execute PL/SQL Program using different
conditional statement (if else, for /while)” under my guidance and supervision, this is
part of partial fulfilment of the requirement for submission of Maharashtra State Board
of Technical Education, Mumbai during Semester third of Academic year 2020-2021.

GUIDE H.O.D PRINCIPAL


Mr. Kazi A. D [Link].R. A Mr. Dhumal S. U.
[Link] [Link]. A.B.I.T (Poly), Satara
A.B.I.T (Poly), Satara A.B.I.T (Poly), Satara

Page 2 of 18
COMPUTER ENGINEERING DATABASE MANAGEMENT SYSTEM

TABLE OF CONTENTS

SR .NO INDEX PAGE NO

1 Brief Introduction 04

2 Aim of the Microproject 05

3 Action Plan 06

4 Resources Required 07

5 Brief Description 08

6 Aim of Microproject 12

7 Actual Producar followed 13

8 Acknowledgement 17

9 Reference 18

Page 3 of 18
COMPUTER ENGINEERING DATABASE MANAGEMENT SYSTEM

Brief Introduction

They’re come situation in real life when we need to make some


decision and based ob these decisions we decide that should we do
next. Similar situation arises in programming also where we need to
make some decision, we will execute the next book of code.
[Link] then else statement
[Link] then statement
[Link] if then statement
[Link] then-else-then-else ladder
The project skill will help the student will understand the pl/sql
statement to retrive the needed information about the table as per their
specified condition og that the desion making statement….

Page 4 of 18
COMPUTER ENGINEERING DATABASE MANAGEMENT SYSTEM

AIM OF MICROPROJECT

Student should have able to execute pl/sql statement using


if then else statement
if then statement
Nested if then statement
if then-else-then-else ladder
this project skill will help the student execute queries to retrive the
needed information for the table as per the specific condition

Page 5 of 18
COMPUTER ENGINEERING DATABASE MANAGEMENT SYSTEM

ACTION PLAN

Action Details of activity Start Date Finish Date Responsible


Plan: Team
Sr. No member
1 Selected the topic for 10-01-21 15-01-21 TEJAS
Micro-project
2 We organised things 15-01-21 20-01-21 KARAN/
required for our project SHUBHAM
3 We browsed the internet 20-01-21 25-01-21 SHUBHAM
for information and raw
data
4 We attended extra 25-01-21 30-01-21 ALL
lectures for our project
topic
5 We made points/notes 01-02-21 06-02-21 TEJAS
on the information we
collected
6 We created a word 08-02-21 13-02-21 KARAN
document with help of
our teacher
7 We made corrections by 15-02-21 20-02-21 ALL
discussing with our
teacher
8 We also created a PDF 22-02-21 26-02-21 SHUBHAM
document to make a
hard copy of the report

Page 6 of 18
COMPUTER ENGINEERING DATABASE MANAGEMENT SYSTEM

Resource Required

Software requirements

[Link]. Name of Specification Qty. Remark


Resource
1. Operation Window XP/7 or Linux 1 Yes
System
2. User Oracle database log 1 Yes
Interface express addition
3. Software MS access software 1 Yes

Page 7 of 18
COMPUTER ENGINEERING DATABASE MANAGEMENT SYSTEM

BRIEF DESCRPTION

TYPE OF OPREATOR

• OVERVIEW OF PL/SQL CONTROL


• Testing Conditions: IF and CASE Statements
• Controlling loop iteration; loop and EXIT statement
• Sequential control: GOTO and NULL statement

Page 8 of 18
COMPUTER ENGINEERING DATABASE MANAGEMENT SYSTEM

Overview of PL/SQL Control Structures

Procedural computer programs use the basic control structures shown


in Figure .

Figure Control Structures

Description of "Figure Control Structures"

The selection structure tests a condition, then executes one sequence


of statements instead of another, depending on whether the condition
is true or false. A condition is any variable or expression that returns
a BOOLEAN value. The iteration structure executes a sequence of
statements repeatedly as long as a condition holds true. The sequence
structure simply executes a sequence of statements in the order in
which they occur.

Page 9 of 18
COMPUTER ENGINEERING DATABASE MANAGEMENT SYSTEM

Testing Conditions (IF and CASE Statements)

The IF statement executes a sequence of statements depending on


the value of a condition. There are three forms of IF statements: IF-
THEN, IF-THEN-ELSE, and IF-THEN-ELSIF. For a description of the
syntax of the IF statement, see IF Statement.

The CASE statement is a compact way to evaluate a single condition


and choose between many alternative actions. It makes sense to
use CASE when there are three or more alternatives to choose from.
For a description of the syntax of the CASE statement, see CASE
Statement.

Page 10 of 18
COMPUTER ENGINEERING DATABASE MANAGEMENT SYSTEM

Relational Operator

The following table shows all the relational operators supported by C


language. Assume variable A holds 10 and variable B holds 20 then –

Operator Description Example

== Checks if the values of two operands are (A == B) is


equal or not. If yes, then the condition not true.
becomes true.

!= Checks if the values of two operands are (A != B) is


equal or not. If the values are not equal, true.
then the condition becomes true.

> Checks if the value of left operand is greater (A > B) is


than the value of right operand. If yes, then not true.
the condition becomes true.

< Checks if the value of left operand is less (A < B) is


than the value of right operand. If yes, then true.
the condition becomes true.

>= Checks if the value of left operand is greater (A >= B) is


than or equal to the value of right operand. not true.
If yes, then the condition becomes true.

<= Checks if the value of left operand is less (A <= B) is


than or equal to the value of right operand. true.
If yes, then the condition becomes true.

Page 11 of 18
COMPUTER ENGINEERING DATABASE MANAGEMENT SYSTEM

Aim of Microproject

PL/SQL has three categories of control statements:

• Conditional selection statements, which run different


statements for different data values.

The conditional selection statements are IF and and CASE.

• Loop statements, which run the same statements with a series


of different data values.

The loop statements are the basic LOOP, FOR LOOP,


and WHILE LOOP.

The EXIT statement transfers control to the end of a loop.


The CONTINUE statement exits the current iteration of a loop and
transfers control to the next iteration.
Both EXIT and CONTINUE have an optional WHEN clause,
where you can specify a condition.

• Sequential control statements, which are not crucial to PL/SQL


programming.

The sequential control statements are GOTO, which goes to a


specified statement, and NULL, which does nothing.

Page 12 of 18
COMPUTER ENGINEERING DATABASE MANAGEMENT SYSTEM

ACTUAL OF MICROPROJECT

IF-THEN-ELSE Statement

• The IF-THEN-ELSE statement is mainly used to select between


two alternatives based on the condition.
• Below is the syntax representation of IF-THEN-ELSE statement.

Syntax for IF-THEN-ELSE Statements:

IF <condition: returns Boolean>


THEN
-executed only if the condition returns TRUE
<action_blockl>
ELSE
-execute if the condition failed (returns FALSE)
<action_block2>
END if;

• In the above syntax, keyword 'IF' will be followed by a condition


which evaluates to 'TRUE'/'FALSE'.
• The control will execute the <action_block1> only if the condition
returns <TRUE>.
• In case of condition evaluates to <FALSE> then, SQL will execute
<action_block2>.
• In any case, one of the two action blocks will be executed.

Note: Whenever condition evaluates to 'NULL', then SQL will treat


'NULL' as 'FALSE'.In this example, we are going to print message
whether the given number is odd or even.

Page 13 of 18
COMPUTER ENGINEERING DATABASE MANAGEMENT SYSTEM

DECLARE
a NUMBER:=11;
BEGIN
dbms_output.put_line (‘Program started');
IF( mod(a,2)=0) THEN
dbms_output.put_line('a is even number' );
ELSE
dbms_output.put_line('a is odd number1);
END IF;
dbms_output.put_line (‘Program completed.’);
END;
/

Code Explanation:

• Code line 2: Declaring the variable 'a' as 'NUMBER' data type and
initializing it with value '11'.
• Code line 4: Printing the statement "Program started".
• Code line 5: Checking the condition, whether modulus of variable
'a' by '2' is 0.
• Code line 6: If '0', then "a is even number" will be printed.
• Code line 7: If the modulus value is not equal to '0', then the
condition returns <FALSE>, so the message "a is odd number"
will be printed.
• Code line10: Printing the statement "Program completed"

Code Output:

Program started.
a is odd number
Program completed.

Page 14 of 18
COMPUTER ENGINEERING DATABASE MANAGEMENT SYSTEM

While loop Statement

WHILE loop statement works similar to the Basic loop statement


except the EXIT condition is at the very beginning of the loop.

It works like an entry-check loop in which execution block will not even
be executed once if the condition is not satisfied, as the exit condition
is checking before execution part. It does not require keyword 'EXIT'
explicitly to exit from the loop since it is validating the condition
implicitly each time of the loop.

WHILE <EXIT condition>


LOOP
<execution block starts>
.
.
.
<execution_block_ends>
END LOOP;

Syntax Explanation:

• In the above syntax, keyword 'WHILE' marks beginning of the


loop and 'END LOOP' marks the end of the loop.
• EXIT condition is evaluated each time before the execution part is
starting executing.
• The execution block contains all the code that needs to be
executed.
• The execution part can contain any execution statement.

Page 15 of 18
COMPUTER ENGINEERING DATABASE MANAGEMENT SYSTEM

While loop program:

DECLARE
a NUMBER :=1;
BEGIN
dbms_output.put_line('Program started');
WHILE (a <= 5)
LOOP
dbms_output.put_line(a);
a:=a+1;
END LOOP;
dbms_output.put_line(‘Program completed' );
END:
/

Code Explanation:

• Code line 2: Declaring the variable 'a' as 'NUMBER' data type


and initializing it with value '1'.
• Code line 4: Printing the statement "Program started".
• Code line 5: Keyword 'WHILE' marks the beginning of the loop,
and it also checks whether the value of 'a' is less than or equal to
5
• Code line 7: Prints the value of 'a'.
• Code line 8: Increments the value of 'a' by +1.
• Code line 9: Keyword 'END LOOP' marks the end of execution
block.
• The code from line 7 and line 8 will continue to execute till 'a'
reaches the value 6, as the condition will return TRUE, and the
control will EXIT from the loop.
• Code line 10: Printing the statement "Program completed"

Output:
Program started
1
2
3
4
5
Program completed
Page 16 of 18
COMPUTER ENGINEERING DATABASE MANAGEMENT SYSTEM

Acknowledgement:
We take this opportunity to express sincere thanks to our project
guide. Mr. Kazi. A.D Under whose guidance our project is done.
We also thanks to all the Computer department teachers for their
valuable guidance, and timely suggestions without which we
could not complete this project work.
Only because of our staff inspiration and instructions we
could achieve satisfactory completion of project work.
Last but not least, we wish to thanks all of those who have helped us
directly or indirectly in this project work.

Page 17 of 18
COMPUTER ENGINEERING DATABASE MANAGEMENT SYSTEM

Reference

PL/SQL Control Statements ([Link])

Oracle PL/SQL WHILE LOOP with Example ([Link])

Page 18 of 18

Common questions

Powered by AI

The IF statement in PL/SQL executes a sequence of statements depending on a single condition and has three forms: IF-THEN, IF-THEN-ELSE, and IF-THEN-ELSIF. It is useful for decision-making scenarios depending on whether a condition evaluates to true or false. On the other hand, the CASE statement is a more compact way to evaluate a single condition to choose between many alternative actions. It is advantageous to use CASE when there are three or more alternatives since it provides a clearer and more organized structure, especially when the number of conditions increases .

Action plans are critical tools for the successful completion of academic projects as they structure the process into clear, manageable steps, assign responsibilities, and establish timelines. In the PL/SQL programming project, the action plan included selecting the topic, organizing resources, gathering information, taking additional lectures, and compiling the report. Each step was time-bound and focused on specific outcomes, which helped in maintaining momentum and ensuring all necessary components were systematically addressed .

Relational operators are critical in decision-making within PL/SQL scripts because they evaluate conditions that determine the execution flow of the program. For example, operators such as '==', '!=', '>', '<', '>=', and '<=' compare values of variables or expressions and return Boolean results used in conditional statements like IF and CASE. In a script, you might use '==' to check if two values are equal before processing a block of code, or '>=' to verify if a condition has been met, such as in credit scoring where an application is rejected only if the score is below a specified threshold .

Students face several challenges while learning PL/SQL programming, such as understanding the syntax and semantics of PL/SQL control structures, managing the logic flow with relational and control operators, and debugging complex queries. Additionally, there may be difficulties in optimally utilizing resources like Oracle databases for effective query execution. These challenges can overwhelm learners without strong foundational concepts or access to adequate guidance, as documented in their engagement with extra lectures and continuous collaboration with instructors for project execution success .

To improve the readability and maintainability of complex PL/SQL programs, several strategies can be adopted: using consistent and descriptive naming for variables and procedures; breaking down complex logic into smaller, well-defined procedures or functions; using CASE statements over nested IFs where multiple alternative scenarios exist; commenting extensively to explain the purpose and logic of blocks of code; and employing indentation and spacing effectively to visually demarcate logical structures. Employing these strategies helps create cleaner code which is easier to understand and modify .

The WHILE loop in PL/SQL functions as an entry-check loop where the exit condition is evaluated before the execution block starts. This means the execution block may not execute at all if the condition is not met from the start. It is preferred in scenarios where pre-testing the condition is required and you want the loop to execute only if the condition is true from the outset. It assures the loop will execute zero or more times depending on the initial condition check .

Sequential control statements in PL/SQL, such as GOTO and NULL, are not crucial but serve specific roles. GOTO allows jumping to a specified statement elsewhere in the program, which can simplify complex flow control scenarios but may also lead to less readable and harder to maintain code. NULL represents a no-operation and can be used in places where syntax requires an action but no operation is intended. These statements should be used cautiously to avoid unintended side-effects and maintain code clarity and maintainability .

In PL/SQL, variable declaration and initialization are essential for preparing storage within the program to store and manipulate data. Within loop constructs, declaring and initializing variables correctly is crucial to control iteration and manage state across iterations. For instance, an index variable in a WHILE loop is typically initialized before the loop starts and updated within the loop body to ensure the loop progresses correctly. Properly managing variables this way prevents logical errors and ensures the loop executes as intended .

Handling NULL values in PL/SQL conditional statements can significantly affect the logic flow because NULL represents an unknown value. When a condition involving NULL is evaluated, it typically returns NULL, which PL/SQL treats as FALSE within conditions like IF or CASE statements. This means that care must be taken to manage NULL values explicitly, such as by using functions like NVL to replace NULL with a default value or by structuring logic to handle NULL explicitly. Failing to do so might lead to unintended pathways in the code execution, potentially overlooking valid branches .

Learning to execute PL/SQL programs using conditional and loop statements provides students with critical problem-solving skills applicable in real-world scenario analysis and decision making. According to the project report, mastering these control structures enhances the ability to retrieve specific information from databases efficiently, design logical programs that respond dynamically to data, and execute complex query manipulations. This core skill set is foundational for developing complex applications and contributes substantially to understanding algorithmic thinking and system development .

COMPUTER ENGINEERING                                                                                            DATABASE MANA
COMPUTER ENGINEERING                                                                                            DATABASE MANA
COMPUTER ENGINEERING                                                                                            DATABASE MANA
COMPUTER ENGINEERING                                                                                            DATABASE MANA
COMPUTER ENGINEERING                                                                                            DATABASE MANA
COMPUTER ENGINEERING                                                                                            DATABASE MANA
COMPUTER ENGINEERING                                                                                            DATABASE MANA
COMPUTER ENGINEERING                                                                                            DATABASE MANA
COMPUTER ENGINEERING                                                                                            DATABASE MANA
COMPUTER ENGINEERING                                                                                            DATABASE MANA

You might also like