Oracle Object-Oriented Programming (OOP)

Source: Internet
Author: User

Since Oracle9i, Oracle is no longer simply a relational database management system. It adds a series of object-oriented features based on the relational database model. Oracle9i is known as object-oriented database. Oracle's object system complies with the Basic Features of Object-oriented Thinking. Many concepts are similar to those in C ++ and JAVA. It has the characteristics of inheritance, heavy load, and polymorphism, but has its own characteristics.

Why should we introduce the object model? Parts can be reused and simplify complex applications.

The following describes Oracle Object-Oriented Programming in detail.

1. Object-oriented TYPE

In PL/SQL, object-oriented programming is based on object types.

1.1 object-oriented type definition syntax

Object Type definitions include Object Type headers (or specification) and object type bodies (bodies ). Object Type headers include object type attributes, functions, and process declarations. Object Type bodies are specific implementations of object types, that is, functions and procedures. Therefore, if the object type contains only attributes, but does not include functions and procedures, you only need to declare the object type header.

Object Type Header declaration Syntax:

Create or replace type type_name as object (
-- Attribute Declaration
Propertyname1 TYPE1,
Propertyname2 TYPE2,
...
Properynamen TYPEn,

-- Function declaration
Member function funcname1 (param1 TYPE1,...) return TYPE11,
Static function funcname2 (param1 TYPE2,...) return TYPE22,
...

-- Process statement
Member procedure procname1 (param1 TYPE1 ,...),
Static procedure procname2 (param1 TYPE2 ,...),
...
);

Object Type Definition Syntax:

Create or replace type body type_name -- No 'as Object'
AS -- NO 'begin'
Member function funcname1 return TYPE11
IS
// Variable definition
BEGIN
// Process
Return var1;
END funcname1;
Static function funcname2 return TYPE22
IS
// Variable definition
BEGIN
// Process
Return var2;
END funcname2;
...
Member procedure procname1 (param1 TYPE1 ,...)
IS
// Variable definition
BEGIN
// Process
END procname1;
Static procedure procname2 (param1 TYPE2 ,...)
IS
// Variable definition
BEGIN
// Process
END procname2;
...
END;

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • Next Page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.