This forum is currently locked. You can't register or post questions at this time. (read more)

Object Type and Methods benefits

All posts relating to Oracle PL/SQL development.

Moderator: Tim...

Anand
Member
Posts: 22
Joined: Thu Jun 07, 2012 2:59 pm

Object Type and Methods benefits

Postby Anand » Sun Jun 17, 2012 6:50 am

Hi Tim,

Could you please share your valueable inputs on following questions?

1. Why and when Object and Object Methods are required?
2. What benefits they provide to the applications?

I know how to create Object Type and their methonds but exactly at what time and purpose I don't know.
I also googled at lot but unable to locate any scenario where Object and Object Methods are required.

P.S: I am asking this because few days back "Code Review Team" of my company has reject my code from performance standpoint ,
saying that Object Type and Methods will be more suitable.The following was my requirement.

**As per our application functionlity , our database require certain parameters(we call them global parameters) to be set through GUI.

My design was,
------------------
1. I had created "GParmeters" table to store the GUI Parameters settings.
2. Also created some functions which can be applied over the GUI parameters values. For example: function to extract comma separated values.

Suggested design by the code review team was:-
---------------------------------------------------------
1. "GParameters" table is fine.
2. In place of standalone function , they suggested me to create "Object" and "Object Methods"(for comma separation).
Their goal was to cache the values of "GParameters" table through the use of Object Constructor funtion
so that the "Object Methods" can be applied on these cached values(for comman separation purpose).
This they think will improve the system performance.

Please suggest what benefits object will produce here:-

Thanks & Regards,
Anand Kumar Ojha

Tim...
Site Admin
Posts: 18437
Joined: Mon Nov 01, 2004 5:56 pm
Location: England, UK
Contact:

Re: Object Type and Methods benefits

Postby Tim... » Sun Jun 17, 2012 7:33 am

Hi.

Let me start by making one clear distinction. We can have objects at two levels.

- Objects can be stored in the database as either columns in a regular table (object-relational) or as object tables.
- Objects can be used in PL/SQL, even if the the underlying tables are purely relational.

Although there is nothing fundamentally wrong with using objects in tables, they can cause problems if 3rd part tools (applications and reporting tools) do not understand them. Even though the object-relational technology in Oracle is very mature, I avoid it at the table level, except for those types provided natively by Oracle (XMLTYPE, OrdImage, OrdVideo etc). Indexing of object data can also be a problem unless you build your own custom indexing cartridges.

With that stated, I believe you are talking about the second option. Using object types in PL/SQL only.

The use of objects in PL/SQL is purely a preference thing. They don't out-perform procedural PL/SQL. They are not necessarily clearer or easier to use. Where they do benefit is when they are being used by client developers who are used to object-orientated programming, because they seem more familiar than regular procedure calls.

Objects often allow you to describe real-life things more naturally than relational tables. For example, lets look at a person. We can create a "Person" object that has all the information relevant to a person in a single object. This data may come from multiple tables (employee, communication_devices, addresses, departments etc.), but as the person object we can present in a single, real-world-like form. That is the advantage.

So why do your company want them? It sounds like they want to be able to pull back objects containing all the relevant data/methods and cache it, so they can repeatedly reference it without going back to the database. From a data perspective this is no different than a record structure to hold the data, but exposing the methods within the type may prevent them from having to hit the database for each method call, so they may benefit.

In reality, the only way to be sure is to do a proof of concept and test it. If it works better then great. If is sucks, you've all learnt a very valuable lesson for the next time it comes up in conversation. :)

Cheers

Tim...
Tim...
Oracle ACE Director
Oracle ACE of the Year 2006 - Oracle Magazine Editors Choice Awards
OakTable Member
OCP DBA 7.3, 8, 8i, 9i, 10g, 11g
OCP Advanced PL/SQL Developer
Oracle Database: SQL Certified Expert
My website: http://www.oracle-base.com
My blog: http://www.oracle-base.com/blog

Anand
Member
Posts: 22
Joined: Thu Jun 07, 2012 2:59 pm

Re: Object Type and Methods benefits

Postby Anand » Sun Jun 17, 2012 8:39 am

Hi Tim,

First of all, thanks a lot for your detail description.

And yes , I was talking about "use of objects in PL/SQL".

And regarding your question , what benefits my company is seeing in using object in my case is that
they are having a strong believe that "Use of objects and object methods within" has the advantage as they doesn't leads to CONTEXT SWITCHING (between SQL and PLSQL engine) due to the fact that "Object and Object Methods is exposed to SQL engine"
whereas this is not true in the case of "simply querying through "GParameter" table and then applying the standalone funtion thereafter(for comma separated value)".

What would you like to say about this?

Thanks & Regards,
Anand Kumar Ojha

Tim...
Site Admin
Posts: 18437
Joined: Mon Nov 01, 2004 5:56 pm
Location: England, UK
Contact:

Re: Object Type and Methods benefits

Postby Tim... » Sun Jun 17, 2012 1:39 pm

Hi.

That doesn't make sense to me. The TYPE BODY is cold in PL/SQL, so any methods will require PL/SQL and therefore a context switch...

Cheers

Tim...
Tim...
Oracle ACE Director
Oracle ACE of the Year 2006 - Oracle Magazine Editors Choice Awards
OakTable Member
OCP DBA 7.3, 8, 8i, 9i, 10g, 11g
OCP Advanced PL/SQL Developer
Oracle Database: SQL Certified Expert
My website: http://www.oracle-base.com
My blog: http://www.oracle-base.com/blog


Return to “Oracle SQL and PL/SQL Development”

Who is online

Users browsing this forum: No registered users and 4 guests

cron