How To Create An Explicit Cursors In Oracle Database

By Manish Sharma

Create Explicit Cursor In Oracle Database

Cursor is a pointer to a memory area called context area. This we have already learnt with all the other details in the previous tutorial. Today in this blog we will learn how to create an explicit database cursor.

As we have already learnt that whenever we execute a DML statement, the oracle server creates an implicit cursor in the background. As these cursors are created by oracle server itself thus user does not have much programmatic control on them. In case if you want to control your own DMLs then you need to write an explicit cursor.

So let’s quickly see how you can create your own database cursor in oracle database.

  v_name VARCHAR2(30);
  --Declare Cursor
  CURSOR  cur_RebellionRider  IS
  WHERE  employee_id  <  105;
  OPEN cur_RebellionRider;
   FETCH cur_RebellionRider INTO v_name;
   EXIT WHEN cur_RebellionRider%NOTFOUND;
  END LOOP;--Simple Loop End
  CLOSE cur_RebellionRider;

We used EMPLOYEE table of HR sample Schema for creating the above explicit cursor. You can watch my Video Tutorial on The Same Topic for line by line explanation of the above code.

Declaration of your cursor can only be done in the “Declaration” section of the PL/SQL block and the rest of the steps of explicit cursor creation cycle must be done in the execution section of a PL/SQL block.

This is a quick tutorial on how to create an explicit cursor in oracle database. Hope you liked it. Do make sure to share this blog on your Facebook or click here to share it on your twitter quickly. Thanks for reading & have a great day!

SQL Script and Presentation used

You can DOWNLOAD SQL script and presentation used in the Video and in this article.

NO SQL Script used in Video and in this article

Do Not Drink & Drive Use My Uber Code "UberRebellionRider"
SignUp using my referral code and get first ride worth $20 FREE

  • Manish Sharma Oracle Rebellion Rider
  • Manish Sharma Oracle certified SQL expert
  • Manish Sharma oracle certified associate
  • Manish Sharma oracle certified professional
  • View Manish Sharma's profile on LinkedIn
  •          View Manish Sharma's profile on LinkedIn