All Products
Search
Document Center

PolarDB:Basic object concepts

Last Updated:Mar 28, 2026

PolarDB for Oracle's Stored Procedure Language (SPL) supports object-oriented programming through object types and object instances. The core constructs are attributes, which describe instance characteristics, and methods, which operate on instances.

Usage notes

Database objects vs. SPL objects

The term "database object" used elsewhere in this documentation refers to database entities such as tables, views, indexes, and users. In this topic and the other topics under "Object types and objects," the terms *object type* and *object* refer to specific data structures in SPL that implement object-oriented programming concepts.

Oracle ADT compatibility

In Oracle, object types in PL/SQL are called abstract data types (ADTs). The SPL implementation of object types is designed to be compatible with Oracle ADTs. PolarDB for Oracle hasn't yet implemented support for all features of object-oriented programming languages — this topic covers only the features that are currently supported.

Key concepts

Object-oriented programming centers on the concept of objects. An *object* represents a real-world entity — a person, place, or thing. The generic definition of a particular kind of entity is called an *object type*. Specific instances, such as "Joe" or "Sally," are *object instances* of the person object type.

Every object type has two components:

  • Attributes: fields that describe particular characteristics of an object instance. For a person object type, attributes might include name, address, gender, date of birth, height, weight, eye color, and occupation.

  • Methods: SPL procedures or functions that perform operations on or related to an object. For a person object type, methods might calculate the person's age, display attribute values, or update them.

Attributes

Every object type must include at least one attribute. An attribute's data type can be:

  • A base data type, such as NUMBER or VARCHAR2

  • Another object type

  • A globally defined collection type created with the CREATE TYPE statement, such as a nested table or varray

Each object instance has its own set of attribute values. When an instance is first created, each attribute is initialized — the initial value may be NULL.

Methods

Methods are SPL procedures or functions defined within an object type. There are three categories:

Member methods

Member methods operate within the context of a specific object instance. They have access to the instance's attributes and can modify them.

Static methods

Static methods operate independently of any object instance. They cannot access or modify instance attributes.

Constructor methods

Constructor methods create a new instance of an object type. A default constructor method is always provided when an object type is defined.

Overloaded methods

In an object type, you cannot define two or more identically named methods of the same type (either a procedure or function) but with different signatures. Such methods are called *overloaded methods*.

A method's signature is determined by three factors: the number of formal parameters, the data types of those parameters, and their order.