PLSQL: DECISION CONTROL STATEMENT: IF, IF-ELSE, IF-ELSIF-ELSE, CASE

31 programming challenges to help you master the fundamentals of DATABASE MANAGEMENT SYSTEM USING ORACLE.

1

Write a PL/SQL block to check if a number is positive.

(IF Statement)

2

Write a PL/SQL block to check if an employee’s salary is greater than 3000.

(IF Statement)

3

Write a PL/SQL block to check if a given number is even.

(IF Statement)

4

Write a PL/SQL block to display a message if today is Monday.

(IF Statement)

5

Write a PL/SQL block to check if a number is divisible by 5.

(IF Statement)

6

Write a PL/SQL block to check whether a number is even or odd.

(IF-ELSE Statement)

7

Write a PL/SQL block to check whether a number is positive or negative.

(IF-ELSE Statement)

8

Write a PL/SQL block to compare two numbers and display the greater one.

(IF-ELSE Statement)

9

Write a PL/SQL block to check whether a student passed (marks ≥ 40) or failed.

(IF-ELSE Statement)

10

Write a PL/SQL block to check if salary is above average (use fixed value).

(IF-ELSE Statement)

11

Write a PL/SQL block to assign grades based on marks:

* ≥ 80 → A

* ≥ 60 → B

* ≥ 40 → C

* else → Fail

(IF-ELSIF-ELSE)

12

Write a PL/SQL block to find the greatest of three numbers.

(IF-ELSIF-ELSE)

13

Write a PL/SQL block to check if a number is:

* Positive

* Negative

* Zero

(IF-ELSIF-ELSE)

14

Write a PL/SQL block to categorize salary:

* High (>5000)

* Medium (3000–5000)

* Low (<3000)

(IF-ELSIF-ELSE)

15

Write a PL/SQL block to calculate bonus based on job role.

(IF-ELSIF-ELSE)

16

Write a PL/SQL block using CASE to display day of week based on number (1–7).

(CASE Statement)

17

Write a PL/SQL block using CASE to assign grades based on marks.

(CASE Statement)

18

Write a PL/SQL block using CASE to check whether a number is even or odd.

(CASE Statement)

19

Write a PL/SQL block using CASE to display department name based on department id.

(CASE Statement)

20

Write a PL/SQL block using CASE to categorize salary (High/Medium/Low).

(CASE Statement)

21

Write a PL/SQL block to print numbers from 1 to 10 but skip number 5 using CONTINUE.

(CONTINUE Statement)

22

Write a PL/SQL block to display only odd numbers between 1 and 20 using CONTINUE.

(CONTINUE Statement)

23

Write a PL/SQL block to skip multiples of 3 while printing numbers 1–15.

(CONTINUE Statement)

24

Write a PL/SQL block to skip employees with salary less than 2000 (use loop).

(CONTINUE Statement)

25

Write a PL/SQL block to exit loop when number reaches 5.

(EXIT Statement)

26

Write a PL/SQL block to print numbers until sum exceeds 50, then exit.

(EXIT Statement)

27

Write a PL/SQL block to exit loop when a negative number is encountered.

(EXIT Statement)

28

Write a PL/SQL block using EXIT WHEN to stop loop when condition is met.

(EXIT Statement)

29

Write a PL/SQL block using IF-ELSIF and CASE together.

(Combined Control Statements)

30

Write a PL/SQL block to process employee salaries using LOOP, CONTINUE, and EXIT.

(Combined Concepts)

31

Write a PL/SQL block to simulate a login system (check username & password using IF-ELSE).

(IF-ELSE Practical)