Results 1 to 4 of 4

Thread: ref cursor

  1. #1
    Join Date
    Dec 2003
    Posts
    1,074

    Unanswered: ref cursor

    Is it possible to create a function which returns a REF CURSOR without placing the cursor declaration in the package and the function in a package body?

    Thanks
    Chuck

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    In 9i there is a pre-defined type SYS_REFCURSOR that you can use instead of declaring your own REF CURSOR type.

    Prior to 9i, you need to declare your own REF CURSOR type in a package specification so that the caller and the function can both see it. It doesn't have to be the same package: you could have a general purpose package like this:
    Code:
    create or replace package utils
      type ref_cursor is ref cursor;
    end;
    Now utils.ref_cursor can be used anywhere in your code.

  3. #3
    Join Date
    Dec 2003
    Posts
    1,074
    Any advantage to using one approach over the other?
    -cf

  4. #4
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    No, it is a matter of preference. My preference (pre-9i) would be to define the ref cursor type once in a single package and use it everywhere, simply because it would irritate me to have to keep defining the "same" type over and over otherwise.

Posting Permissions

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