Skip to Main Content
  • Questions
  • Object types with body Vs PL/SQL packages

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Boobal.

Asked: June 04, 2016 - 8:20 am UTC

Last updated: June 09, 2016 - 3:21 am UTC

Version: 12c

Viewed 1000+ times

You Asked

Hello Mr. Tom,

I have always wondered about the object types in Oracle, which allows us to create methods similar to the PL/SQL packages. I am not able to find any difference between these two objects as both works similarly IMHO. Is there any performance implication or unknown talent in any of these objects?

Thank you,
Boobal Ganesan

and Connor said...

They are really designed with different needs in mind. Code in object types are related to the OO programming model, where we have methods and constructors that pertain to the object itself.

Code in packages might pertain to something totally independent of any form of object, or even a database table. For example, dbms_output is for putting output back to the client.

Obviously, anything you can code in a procedural model, you could transpose to an object paradigm, and vice-versa. eg, UTL_FILE for file I/O could easily be converted into a type where a "file" is the object, and the methods are there for opening/writing etc.

There is nothing to stop you from getting the benefits of both. For example, we have many "procedural" packages that use XMLType, which in itself is a type that takes advantage of the methods/constructors

Hope this helps.

Rating

  (2 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Best Response!!

Boobal Ganesan, June 09, 2016 - 4:22 am UTC

I was actually waiting for your to reply their differences, but you got me by explaining their purpose of creation. Thank you Connor!!

Thanks,
B

Best Response!!

Boobal Ganesan, June 09, 2016 - 4:23 am UTC

I was actually waiting for your to reply their differences, but you got me by explaining their purpose of creation. Thank you Connor!!

Thanks,
B

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library