Object Type Specification

The specification is the interface of the object type. It contains declarations of attributes and methods. The specification contains public declarations, which are accessible outside the object type. You can call object methods and attributes using dot notation. In the interface part of object type, you are to declare all attributes before the methods, otherwise PL/SQL compilation error will occur.

If the object type specification has only attributes, it is not necessary to create type body. You can’t declare constants, exceptions, cursors, or types in the object specification. You must declare at least one attribute but less than 1000 ones in the specification.

Attribute name attribute must be unique within the object type.

PL\SQL does not allow creating attributes of such data types:

  • LONG and LONG RAW
  • ROWID and UROWID
  • The PL/SQL-specific types BINARY_INTEGER (and its subtypes), BOOLEAN, PLS_INTEGER, RECORD, REF CURSOR, %TYPE, and %ROWTYPE
  • Types defined inside a PL/SQL package

Generally object method is declared using the keyword MEMBER or STATIC. To call MEMBER methods the instance of this type is to be created. STATIC methods can be invoked on object types when no object of such type exists. Like other subprograms, methods have two parts: a declarative one and a subprogram body. The declarative part consists of the method name, parameter list, and return type(for functions). The body is the code that is executed to perform a specific task.

Specify MAP or ORDER methods to provide the possibility of comparison and sorting of objects.

Creating an Object Type Specification

  1. In the Database Explorer window, expand the User Types folder.
  2. Right-click the Object Types folder, and then click New Object Type in the shortcut menu.
  3. Fill a template with statements. dbForge Fusion adds the CREATE/REPLACE words for you.
  4. Save the document.

Editing an Object Type Specification

  1. In the Database Explorer window, expand the User Types folder.
  2. Expand the Object Types folder.
  3. Right-click a required object, and then click Open Type in the shortcut menu.

To delete an object type, right click a required object, and then click Delete in the shortcut menu.