Pl/sql -Member function

Dear Expert,
  I can't understand what is member function in below example and
the body return self -
Why we need to use member function here.

Please explain to me .Thanks & regards



 CREATE TYPE object_type AS OBJECT
  2  ( x INT
  3  , y DATE
  4  , z VARCHAR2(1)
  5  , MEMBER FUNCTION print RETURN VARCHAR2
  6  );
  7  /

Type created.

SQL> CREATE TYPE BODY object_type AS
  2     MEMBER FUNCTION print RETURN VARCHAR2 IS
  3     BEGIN
  4        RETURN TO_CHAR(SELF.x)            || ',' ||
  5               TO_CHAR(SELF.y,'YYYYMMDD') || ',' ||
  6               z;
  7     END;
  8  END;
  9  /

daprjoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
>Why we need to use member function here.
you ask a question we cannot answer here

the member function will allow to centralize code related to the type into the type itself.

SELF refers to the object_type instance itself, so when you create a variable of that type, you can use

yourvariable.print  

to get some of the variable's member data to be returned in the given format.

hope this explains
0
daprjoAuthor Commented:
Dear Expert,

       U no need to answer the above question.
       Can u please explain to me member procedure and member function in object type
      with simple  examples.
     Thanks & regards
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
I don't know how the example could be simplified ...
the type has 3 members, x,y and z.

to function returns the values of those 3, with a "," in between the 3 values, and ensureing the date is formatted YYYYMMDD

0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

slightwv (䄆 Netminder) Commented:
I'll defer you to the docs since they can explain it better than we can:
http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28371/adobjbas.htm#i477669

If you have a specific question about the code you posted we can try to answer that:

the print member returns a comma separated list for the three objects in the type.  It converts 'x' to a character then converts the 'Y' date to a formated character string and tacks on 'Z', all concatenated together with a ','.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
daprjoAuthor Commented:
Dear Expert,
How we can effectively use this object in pl/sql procedures
0
slightwv (䄆 Netminder) Commented:
>>How we can effectively use this object in pl/sql procedures

That depends on your requirements.  From the code you posted, at some time someone found it necessary to create a comma separated list for those three objects.

You would use it in PL/SQL when you needed the list in that format.



0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.