PL/SQL Cursor Exercises: FETCH single record and single column from a table
PL/SQL Cursor: Exercise-15 with Solution
Write a program in PL/SQL to FETCH single record and single column from a table.
Sample Solution:
PL/SQL Code:
DECLARE
v_emp_name VARCHAR2(50);
CURSOR emp_cur_name IS
SELECT first_name
FROM employees
WHERE employee_id = 105;
BEGIN
OPEN emp_cur_name;
FETCH emp_cur_name
INTO v_emp_name;
dbms_output.put_line('The name of the employee is:’
|| v_emp_name);
CLOSE emp_cur_name;
END;
/
Sample Output:
SQL> / The name of the employee is:David PL/SQL procedure successfully completed.
Flowchart:
Improve this sample solution and post your code through Disqus
Previous: Create a PL/SQL block to increase salary of employees in the department 50 using WHERE CURRENT OF clause.
Next: Write a program in PL/SQL to FETCH more than one record and single column from a table.
What is the difficulty level of this exercise?
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework