Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2012
    Posts
    13

    Unanswered: Ref Cursor v/s Cursor

    What is the difference between Ref cursor and cursor?
    Is it true that, Ref cursor could be used for processing more than one SELECT query?
    If true then, can someone explain with an example?

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Jun 2012
    Posts
    13
    Hi,
    Above links helped to understand cursors.
    Thanks for this.
    I need an example of Ref cursor which has more than one Select queries and how the ref cursors work with more than one select queries.

  4. #4
    Join Date
    Jan 2012
    Posts
    84
    What do you mean by "Ref cursor which has more than one Select queries" ?

    Actually the ref cursor can be opened only for one and only one select statement,follow this link for syntax: OPEN FOR Statement

  5. #5
    Join Date
    Jun 2012
    Posts
    13

    Resolved

    Thanks for this.
    While checking the difference between Ref Cursor and Cursor, I found that Ref Cursor may contain more than one SQL block. I wanted to confirm this, so I posted.
    "We can one SQL block in Cursor, If Ref Cursor accepts more than one SQL block then how it works?" was my query.
    It's resolved now.

  6. #6
    Join Date
    Jan 2012
    Posts
    84
    I guess that the author of this sentence meant,
    that "normal" cursors are "static" - the cursor is bond to one SLQ statement at compile time,
    and cannot change at the runtime.
    Ref cursors can be bond (opened) for different SQL statementts at runtime,
    for example you can do something like this with ref cursor:
    Code:
      ref_cur  REF_CURSOR;
    BEGIN
      IF some_condition THEN
          OPEN ref_cur FOR SELECT a, b, c FROM table1 WHERE ....
      ELSE
          OPEN ref_cur FOR SELECT x, y, z FROM table2 WHERE
      END;
    
      .... process rows from ref_cur

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •