Show you the Oracle explicit cursor

Source: Internet
Author: User

Oracle explicit cursors are a type of important cursors. The following describes the usage of Oracle explicit cursors in detail. We hope you can learn more about Oracle explicit cursors.

Oracle explicit cursor:

Oracle explicit cursor Definition Format:

CURSOR name (parameter) [Return Value Type] IS

Select statement

Example

 
 
  1. set serveroutput on  
  2.  
  3. declare  
  4.  
  5. cursor emp_cur ( p_deptid in number) is  
  6.  
  7. select * from employees where department_id = p_deptid;  
  8.  
  9. l_emp employees%rowtype;  
  10.  
  11. begin  
  12.  
  13.  dbms_output.put_line('Getting employees from department 30');  
  14.  
  15. open emp_cur(30);  
  16.  
  17.  loop  
  18.  
  19.  fetch emp_cur into l_emp;  
  20.  
  21.  exit when emp_cur%notfound;  
  22.  
  23.  dbms_output.put_line('Employee id '|| l_emp.employee_id || ' is ');  
  24.  
  25.  dbms_output.put_line(l_emp.first_name || ' ' || l_emp.last_name);  
  26.  
  27.  end loop;  
  28.  
  29.  close emp_cur;  
  30.  
  31.  dbms_output.put_line('Getting employees from department 90');  
  32.  
  33. open emp_cur(90);  
  34.  
  35.  loop  
  36.  
  37.  fetch emp_cur into l_emp;  
  38.  
  39.  exit when emp_cur%notfound;  
  40.  
  41.  dbms_output.put_line('Employee id '|| l_emp.employee_id || ' is ');  
  42.  
  43.  dbms_output.put_line(l_emp.first_name || ' ' || l_emp.last_name);  
  44.  
  45.  end loop;  
  46.  
  47.  close emp_cur;  
  48.  
  49. end;  
  50.  
  51. /  

Use instances of Oracle stored procedures

Oracle command line custom editor vi

Implementation of oracle command line Logon

How to add tablespaces in ORACLE

Syntax for creating views in Oracle

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.