PL/SQL - SPLessons

PL/SQL Object Oriented

Chapter 31

SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

PL/SQL Object Oriented

PL/SQL Object Oriented

shape Description

PLSQL Object Oriented allows users to define the kind of object that is helpful while designing the object oriented programming in the Oracle database. The composite type of objects will be created under the object types. And, real world objects containing some particular structure will be implemented using the object operating methods. These objects contain specific methods and attributes. These attributes are the object properties and are used for storing the state of an object. And, methods are used for behavior modelling.

shape Conceptual

shape Example

The following is an example for creating a table. By using the CREATE OR REPLACE statement, the objects can be created. The following is the sample select articulation that is created using few attributes.


(house_no varchar2(10),

street varchar2(30),

city varchar2(20),

state varchar2(10),

pincode varchar2(10));

Type created.

Instantiating an object

shape Description

While defining the type of an object, it provides a plan for that object. To use these objects, one needs to create an instance to that object. The methods and attributes of an object can be executed using the access operator. and instance name.

shape Examples

The following example explains a sample program for object programming method.

  2  residence address;
  3  BEGIN
  4  residence :=address('104/A','K.G.Road','Edmold','Texas','201300');
  5  dbms_output.put_line('House No:'||residence.house_no);
  6  dbms_output.put_line('Street:'||residence.street);
  7  dbms_output.put_line('City:'||;
  8  dbms_output.put_line('State:'||residence.state);
  9  dbms_output.put_line('Pincode:'||residence.pincode);
 10  END;
 11  /
House No:104/A
PL/SQL procedure is successfully completed.

The above example displays the output of an address.

Member methods

shape Description

These strategies are used for adjusting the qualities of objects. The body of these objects are represented by using the CREATE TYPE BODY explanations. The comparison method consists of two sub-methods, they are:

Map method

The functions that are defined in the map method will completely depend on the attributes of other values.

Order method

To compare two objects, order methods will define some internal logic such that these methods can be easily accessed.


shape Points

  • PLSQL Object Oriented – Allows users to define various types of objects.
  • Instantiating an object – Executes methods and attributes inside the objects.
  • Member methods – These are used for adjusting the qualities of an object.
  • Map methods – The map functions will completely depend on other attribute values.
  • Order method – Internal logic is implemented to compare two objects.