Cursor For Loop With Parameterized Explicit Cursor In Oracle Database

By Manish Sharma

Cursor For Loop In Oracle Database vol.2

The following tutorial requires the knowledge of “Parameterized Cursor” and “Cursor For Loop” beforehand. So for better understanding I highly suggest you to check out the respective blogs to learn the concepts.

The question which was left unattended in the previous tutorial was how to create a cursor for loop with a parameterized cursor in Oracle database? Hence today in this PL/SQL tutorial we will learn how to create cursor for loop with parameterized cursor.

Using cursor for loop, working with parameterized cursor is as easy as working with simple explicit cursor. Checkout the example given below.

Example1. Cursor For Loop With Parameterized Cursor

  CURSOR cur_RebellionRider( var_e_id NUMBER) IS
  SELECT first_name, employee_id FROM employees
  WHERE employee_id > var_e_id;
  FOR l_idx IN cur_RebellionRider(200)
   DBMS_OUTPUT.PUT_LINE(l_idx.employee_id||' '||l_idx.first_name);

You can pass the values for the parameters of your cursor just by simply writing the argument right after the name of your cursor in loop statement as shown in the above example (Statement In bold). Always remember to enclose the arguments inside the parenthesis.

Read the previous blog and find out how to create a cursor for loop with Inline Cursor declaration.

That’s it for today on cursor for loop with parameterized cursor. Do make sure to share this blog with your friends and colleagues on your Facebook or other social media. You can also click here to quickly share this blog on your twitter. Remember now you can win RebellionRider merchandise bag by sharing the content, just make sure to tag me.

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