Skip to Main Content
Oracle PL/SQL for DBAs
book

Oracle PL/SQL for DBAs

by Arup Nanda, Steven Feuerstein
October 2005
Intermediate to advanced content levelIntermediate to advanced
454 pages
14h 44m
English
O'Reilly Media, Inc.
Content preview from Oracle PL/SQL for DBAs

What’s the Difference?

In PL/SQL, an implicit cursor is one that is defined as it is being executed. Here’s an example:

    DECLARE
      v_date DATE;
    BEGIN
      SELECT order_date
        INTO v_date
        FROM orders
       WHERE order_number = 100;
    END;

As the code was executing, it created a cursor to select the order_date for order 100. Thus, the cursor was implicitly defined when the code executed.

An explicit cursor is one that is defined before it actually gets executed. Here’s a simple example:

    DECLARE
      CURSOR curs_get_od IS
      SELECT order_date
        FROM orders
       WHERE order_number = 100;
      v_date DATE;
    BEGIN
      OPEN curs_get_od;
      FETCH curs_get_od INTO v_date;
      CLOSE curs_get_od;
    END;

The implicit version was much easier to write and required a lot less typing, so the initial reaction may be to go with that choice. However, explicit cursors have other benefits that make the extra typing worthwhile within PL/SQL code, as described in the next two sections.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Oracle PL/SQL Best Practices

Oracle PL/SQL Best Practices

Steven Feuerstein
Expert Oracle PL/SQL

Expert Oracle PL/SQL

Ron Hardman, Michael McLaughlin
Oracle PL/SQL For Dummies

Oracle PL/SQL For Dummies

Michael Rosenblum, Paul Dorsey

Publisher Resources

ISBN: 0596005873Supplemental ContentErrata Page