Practical 1: 1. Write A PL/SQL Block To Display The Message "Hello World"
Practical 1: 1. Write A PL/SQL Block To Display The Message "Hello World"
Practical 1
2. Write a PL/SQL block which will read a number from the user and display it on the screen.
3. Write a PL/SQL block to read a message from user and display it.
Page 1 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
4. Write a PL/SQL block to display the area of a rectangle when length and breadth are
accepted by the user.
Page 2 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
6. Write a PL/SQL block to print the sum of two numbers accepted by user.
7. Write a PL/SQL block to print the message ‘You can lead a horse to water but you can't
make him drink’.
Page 3 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
8. Write a PL/SQL block to print the name and job of an employee who is working as CLERK
earning salary of Rs 1300/-.
9. Write a PL/SQL block to calculate Simple Interest where principle, rate and time are
accepted by the user
Page 4 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
10. Write a PL/SQL block to calculate the area of the circle and store the radius and area in a
table AOC (radius, area).
12. Write a PL/SQL block to print the total number of employees working as Manager in
deptno 10.
Page 5 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
13. Write a PL/SQL block to print the total salary of the employees from the employee table
.
Page 6 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
Page 7 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
3. Write a PL/SQL program to calculate the area of a circle and insert the area and radius
in a table aoc (sno,radius,area) till radius is less than 10.
Page 8 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
Page 9 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
6. Write a PL/SQL program to count number of employees in dept 10, and if they are
greater than 3 print the count otherwise do nothing.
Page 10 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
9. Write a PL/SQL block using CASE statement to accept the owner name from the user.
The user name can be SYS, SYSTEM, HR or SCOTT. If the owner name is SYS then
print the result is ‘The Owner is SYS’. If the owner name is SYSTEM then print the
result is ‘The Owner is SYSTEM’. If the owner name is HR then print the result is ‘The
Owner is HR’. If the owner name is SCOTT then print the result is ‘The Owner is
SCOTT’. Otherwise print ‘Invalid Choice’.
Page 11 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
10. Write a PL/SQL block to find factorial of a number which is accepted by the user and
store it under the table fac(num,fact).
Page 12 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
11. Write a PL/SQL to read a number and check whether it is greater than 100 or not and
print appropriate message.
Page 13 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
12. Write a PL/SQL to read the salary of an employee 7900 and display the appropriate
message if it lies in the range of 1000 and 5000.
13. Write a PL/SQL to swap two numbers and display the swapped numbers.
14. Write a PL/SQL block to update the salary of the employee with 1000 when total
number of employees in a particular department is greater than 3.
Page 14 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
15. Write a PL/SQL block to delete the records of the table employee by accepting the table
name from the user.
16. Write a PL/SQL to check whether the character entered is a vowel or not.
Page 15 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
Page 16 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
18. Write a PL/SQL block using case statement to print the salary as high if it is greater
then 10000, moderate if it is between 5000 and 10000 and low if it is less than 5000.
The salary has been taken as an input of a specific employee whose empid is accepted
by the user.
Page 17 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
19. Write a PL/SQL block using case statement to perform addition, subtraction,
multiplication and division for the individual choices a ,s ,m, d. The division can only
take place if the divisor is greater than 0 else error message should be printed.
Page 18 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
Page 19 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
20. Write a PL/SQL block to print the numbers from 1 to 10 using While and For Loop.
Page 20 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
Page 21 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
22. Write a PL/SQL block to calculate the area of a circle till radius less than 10.
23. Write a PL/SQL block to display the number of employees when the deptno is inputted
by the user.
Page 22 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
25. Write a PL/SQL block to display the appropriate day of the week according to the
choice made by the user.
Page 23 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
26. Create a PL/SQL block that has four sections. Each section should output a statement.
Use labels and the Goto command to output the section messages in the following
order:
Section 3 Section 2 Section 1 Section 4
Page 24 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
27. Write a PL/SQL block to check whether the entered year is a leap year or not.
28. Write a PL/SQL block to display the numbers from 1 to 10 using EXIT and EXIT
WHEN statement.
Page 25 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
Page 26 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
30. Write a PL/SQL block to get the details of marks (rollno, marks1, marks2, grade) out
of 100 for marks1 and marks2 respectively. Display the grade in table marks using if
statement as specified below
If stud_pecent > 70 then grade is ‘A’
If stud_pecent > 60 and <70 then grade is ‘B’ else give grade ‘C’.
Page 27 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
31. Write a PL/SQL block to book a ticket for a movie. The tickets are of two type’s deluxe
rows (D) and Ordinary rows (O). While booking the ticket the customer may ask ‘D’
or ‘O’ and number of ticket. For deluxe the rate is 350 and for ordinary 200. Find the
total amount that the customer will pay and number of tickets (using case statement).
Page 28 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
Page 29 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
1. Write a PL/SQL block to create a sequence by using cycle and insert the values in a table,
altering sequences.
Page 30 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
2. Write a sequence as 10, 20, 30 ..... 100 and bind it with the table product (product no,
product name).
Page 31 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
Page 32 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
Page 33 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
Page 34 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
4. Create a procedure and a function to display the greatest among two numbers.
Page 35 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
Page 36 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
5. Create a procedure and a function to display the employee name whose employeeno is
accepted by the user.
Page 37 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
6. Create a procedure and a function to display the sum of salary of the employees
whose job is accepted by the user.
Page 38 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
Page 39 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
Page 40 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
11. Create a package with a function and procedure to find the sum of first 10 natural
numbers.
Page 41 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
12. Create a package with a function and procedure to print the prime numbers between 1
to 50.
Page 42 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
Page 43 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
Page 44 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
Page 45 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
1. To update the total hours of project when hours of employee has been updated for that
particular project.
Page 46 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
Page 47 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
4. Create a trigger to update the salary of employees and to show the old salary, new salary
and the difference.
Page 48 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
5. Create a trigger to delete the record of an employee and insert the deleted record in
DEL_EMP_REC table. In this case, DEL_EMP_REC is table which will hold the deleted records
of an employee.
Page 49 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
Page 50 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
3. Create a table of 10 colors, print them. Delete the color at location 5 and print the
remaining elements.
Page 51 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
Page 52 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
5. Using Index by table type, create a type of numbers indexed by binary integer to store
the values from 1 to 10 at continuous index position. Delete the value at position 6
and display all the values.
Page 53 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
1. Using rowtype variable, display the records of the employee whose employee no is
given by the user.
Page 54 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
Page 55 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
Page 56 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
3. Using User based record, create a book type , read and display the values for specific
attributes of book type.
Page 57 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
2. Write a PL/SQL block to raise an exception when an employee name does not start with
‘A’.
Page 58 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
Page 59 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
Page 60 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
5. Write a PL/SQL block to raise an exception when data record is not found in the table.
Page 61 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
2. Write a PL/SQL block to raise an exception when an employee name does not start with
‘A’.
Page 62 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
Page 63 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
Page 64 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
5. Write a PL/SQL block to raise an exception when data record is not found in the table.
Page 65 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
1. Write a PL/SQL block to UPDATE the salary of the employee by 500 whose
department number is given by the user and display the number of rows if
UPDATED. Otherwise DISPLAY the message ‘No Records Updated’ by using
IMPLICIT CURSOR.
Page 66 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
2. Write a Pl/SQL block using cursor to display the employee names and their salaries till the
record is found using while loop.
Page 67 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
3. Write a PL/SQL block to DISPLAY the employee name along with their jobs using BASIC
LOOP.
Page 68 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
4. Write a PL/SQL block to display the employee names and their jobs using for loop.
Page 69 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
5. Write a PL/SQL block using cursor to display the name and job of employee who are
working as ‘MANAGER’. The value of the job as ‘MANAGER’ should be read by the user.
6. Write a PL/SQL block to display the details of the employee who are working in
department 30 with the help of REF CURSOR.
Page 70 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
7. Write a PL/SQL block to check whether the CURSOR is OPEN or not and to DISPLAY the
appropriate message using EXPLICIT CURSOR.
8. Write a PL/SQL block to DISPLAY the employee name and their hire date using FOR LOOP.
Page 71 of 72
Omkar Sanjay Narkar Roll no: 318 SYIT
9. Write a PL/SQL block to DISPLAY the name of the employee whose name starts with ‘A’
and department is 20, where department number is passed by the user.
10. Write a PL/SQL block to DISPLAY the employee number and employee name who are
working as ‘MANAGER’ and earning salary greater than 1000.
Page 72 of 72