w3resource

PL/SQL Cursor Exercises with Solution

PL/SQL Cursor [ 50 exercises with solution ]

1. Write a program in PL/SQL to show the uses of static PL/SQL statement.

Click me to see the solution

2. Write a program in PL/SQL to show the uses of CURVAL and NEXTVAL with a sequence name.

Click me to see the solution

3. Write a program in PL/SQL to find the number of rows effected by the use of SQL%ROWCOUNT attributes of an implicit cursor

Click me to see the solution

4. Write a program in PL/SQL to show the uses of implicit cursor without using any attribute.

Click me to see the solution

5. Write a program in PL/SQL to show the uses of SQL%FOUND to determine if a DELETE statement affected any rows.

Click me to see the solution

6. Write a program in PL/SQL to show the uses of SQL%NOTFOUND to determine if a UPDATE statement affected any rows.

Click me to see the solution

7. Write a program in PL/SQL to create a table-based record using the %ROWTYPE attribute.

Click me to see the solution

8. Write a program in PL/SQL to display a table based detail information for the employee of ID 149 from the employees table.

Click me to see the solution

9. Write a program in PL/SQL to display a cursor based detail information of employees from employees table.

Click me to see the solution

10. Write a program in PL/SQL to retrieve the records from the employees table and display them using cursors.

Click me to see the solution

11. Write a program in PL/SQL to declare a record datatype with same datatype of tables using %TYPE attribute.

Click me to see the solution

12. Write a program in PL/SQL to create an implicit cursor with for loop.

Click me to see the solution

13. Write a program in PL/SQL to create an explicit cursor with for loop.

Click me to see the solution

14. Create a PL/SQL block to increase salary of employees in the department 50 using WHERE CURRENT OF clause.

Click me to see the solution

15. Write a program in PL/SQL to FETCH single record and single column from a table.

Click me to see the solution

16. Write a program in PL/SQL to FETCH more than one record and single column from a table.

Click me to see the solution

17. Write a program in PL/SQL to FETCH multiple records and more than one columns from the same table.

Click me to see the solution

18. Write a program in PL/SQL to FETCH multiple records and more than one columns from different tables.

Click me to see the solution

19. Write a program in PL/SQL to FETCH multiple records with the uses of nested cursor.

Click me to see the solution

20. Write a program in PL/SQL to FETCH records with nested Cursors using Cursor FOR Loops.

Click me to see the solution

21. Write a program in PL/SQL to print a list of managers and the name of the departments.

Click me to see the solution

22. Write a program in PL/SQL to insert data into two tables from one table using cursor.

Click me to see the solution

23. Write a program in PL/SQL to insert data into two tables from one table using an implicit cursor.

Click me to see the solution

24. Write a program in PL/SQL to create a cursor displays the name and salary of each employee in the EMPLOYEES table whose salary is less than that specified by a passed-in parameter value.

Click me to see the solution

25. Write a program in PL/SQL to show the uses of fetch one record at a time using fetch statement inside the loop.

Click me to see the solution

26. Write a program in PL/SQL to fetch the first three rows of a result set into three records using Same explicit cursor into different variables.

Click me to see the solution

27. Write a PL/SQL block to show the uses of a variable in explicit cursor query, and no result set is affected despite that value of the variable is incremented after every fetch.

Click me to see the solution

28. Write a PL/SQL block to display department name, head of the department,city, and employee with highest salary.

Click me to see the solution

29. Write a PL/SQL block to display the department name, name of the manager, number of employees in each department, and number of employees listed in job_history.

Click me to see the solution

30. Write a block in PL/SQL to displays employee name and number of jobs he or she done at past. Displays employee name and job count by job.

Click me to see the solution

31. Write a block in PL/SQL to display the name of department and their head.

Click me to see the solution

32. Write a PL/SQL program to display the name of the employee and increment percentage of salary according to their working experiences.

Click me to see the solution

33. Write a PL/SQL block to show the uses of a variable in explicit cursor query, and the result set is affected with the value of the variable is incremented after every fetch.

Click me to see the solution

34. Write a PL/SQL block to show the uses of a virtual column in an explicit cursor query.

Click me to see the solution

35. Write a PL/SQL block to display the employee ID, first name, job title and the start date of present job.

Click me to see the solution

36. Write a PL/SQL block to display the name of department the their costliest employee.

Click me to see the solution

37. Write a PL/SQL block to display the last name, first name and overpaid amount by using parameters.

Click me to see the solution

38. Write a PL/SQL block to display the number of employees by month. Print number of employees by month

Click me to see the solution

39. Write a PL/SQL block to display the last name of manager, and their departments for a particular city, using parameters with a default value in explicit cursor.

Click me to see the solution

40. Write a PL/SQL block to find out the start date for current job of a specific employee.

Click me to see the solution

41. Write a PL/SQL block to display the last name, first name and overpaid amount by adding formal parameters and specify a default values for the added parameters.

Click me to see the solution

42. Write a block in PL/SQL to display the first name, job title and start date of employees.

Click me to see the solution

43. Write a block in PL/SQL to print the department name, head of the department, city and number of employees are working in that department.

Click me to see the solution

44. Write a block in PL/SQL to print the specific number of rows from a table.

Click me to see the solution

45. Write a block in PL/SQL to print a dotted line in every 6th line.

Click me to see the solution

46. Write a block in PL/SQL to display the first department with more than five employees.

Click me to see the solution

47. Write a block in PL/SQL to print a report which shows that, the employee id, name, hire date, and the incentive amount they achieved according to their working experiences, who joined in the month of current date.

Click me to see the solution

48. Write a block in PL/SQL to shows how are records are declared and initialized.

Click me to see the solution

49. Write a block in PL/SQL to show the uses of subquery in FROM clause of parent query in an explicit cursor.

Click me to see the solution

50. Write a block in PL/SQL to show the uses of correlated subquery in an explicit cursor.

Click me to see the solution



Follow us on Facebook and Twitter for latest update.