Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Cursors

A cursor is a handle to a private SQL area that points to an entry in the shared pool consisting of the parsed statement. It consists of session-specific information, such as bind variables, the cursor state, the current position in the row in the case of a select statement, and so on.

Cursors in PL/SQL (Explicit and Implicit)

Let's look at an example of a cursor in PL/SQL. Assume that we've already created a table, t1, and inserted numbers from 1 to 5 into it:

benchmark@ORA10G> create table t1 ( x number);

Table created.

benchmark@ORA10G> insert into t1
  2  select rownum
  3  from all_objects
  4  where rownum <= 5;
5 rows created.

benchmark@ORA10G> commit;

Commit complete.

Now we can declare a cursor explicitly in PL/SQL and retrieve its contents:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint