Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2005
    Location
    Arlon - Belgium
    Posts
    20

    Question Unanswered: How to return a NOCOPY value with a function?

    Hi,

    I want to return a value from a function...

    something like:
    Code:
    FUNCTION get_name()
    RETURN VARCHAR2
    IS
    name VARCHAR2;
    BEGIN
       /** do something with name here */
       return name;
    END;
    But I should like the returned object is like a "pointer" to the VARCHAR2.
    (Same as a NOCOPY on a parameter function)

    Is that possible???

    Thanks a lot

    Stephane

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    No. The difference is that with a parameter, you are passing the procedure a pointer to data in your callng program.

    Here you are trying to return to the calling program a pointer to a variable in your function. But that variable only exists temporarily while the function is running, so there is nothing to point to!

  3. #3
    Join Date
    Jun 2005
    Location
    Arlon - Belgium
    Posts
    20

    Red face How to return a NOCOPY value with a function?

    Sorry...

    I simplifiated to much my previuos code...

    Let me try again:

    1) I have an instance of an object (declared and assigned in an package variable) A global object (type).

    2) I want to have a function that returns a pointer to that object (with a NOCOPY). A function named let say getInstance(). --> if the object already is instanciate, the reference will be given, if not, a new object will be created.
    (like the singleton pattern)

    3) I want to create a procedure where I will have something like:
    Code:
    PROCEDURE doSomething (
    context    IN       globalObject%Type DEFAULT globalObject.getInstance()
    )
    BEGIN
      --DoSomething like
      context.getParameters();
    END;
    The idea is if I don't pass the context as param to my doSomething procedure the procedure globalObject.getInstance() will initialize the context variable.

    I should like that the globalObject.getInstance() returns an NOCOPY object.

    Is that possible???

    Thanks.

    Stephane

  4. #4
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Sorry, this is way over my head! I never program with objects...

Posting Permissions

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