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

  • pl/sql

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

الأجوبة

DECLARE
    emp_first_name VARCHAR2(35);
    emp_last_name  VARCHAR2(35);
	zemp_id NUMBER:=&employee_id;
BEGIN
    SELECT first_name,
           last_name
    INTO   emp_first_name, emp_last_name
    FROM   employees
    WHERE  employee_id = zemp_id;

    dbms_output.Put_line ('Employee name: '
                          || emp_first_name
                          ||' '
                          ||emp_last_name);
EXCEPTION
    WHEN no_data_found THEN
      dbms_output.Put_line ('There is no employee with the ID '||to_char(zemp_id));
END; 
/ 

Sample Output:

SQL> /
Enter value for employee_id: 485
old   4:        zemp_id NUMBER:=&employee_id;
new   4:        zemp_id NUMBER:=485;
There is no employee with the ID 485

PL/SQL procedure successfully completed.

SQL> /
Enter value for employee_id: 147
old   4:        zemp_id NUMBER:=&employee_id;
new   4:        zemp_id NUMBER:=147;
Employee name: Alberto Errazuriz

PL/SQL procedure successfully completed.

PL/SQL opens an implicit cursor  with the SELECT INTO statement and after the SELECT INTO
statement completes, closes the implicit cursor.
هل كان المحتوى مفيد؟

معلومات ذات صلة

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...