Q:

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

0

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

DECLARE
  v_emp_name VARCHAR2(20);
  CURSOR cur_emp_name IS
    SELECT first_name
    FROM   employees;

BEGIN
  OPEN cur_emp_name;
  LOOP
    FETCH cur_emp_name
    INTO  v_emp_name;
    EXIT
  WHEN cur_emp_name%NOTFOUND;
    dbms_output.put_line('Name of employee: ’
    || v_emp_name);
  END LOOP;
  CLOSE cur_emp_name;
END;
/

Sample Output:

SQL> /
Name of employee: Ellen
Name of employee: Sundar
Name of employee: Mozhe
Name of employee: David
Name of employee: Hermann
Name of employee: Shelli
Name of employee: Amit
Name of employee: Elizabeth

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now