Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Semestr2 / 1 - Oracle / Oracle selected docs / Database concepts.pdf
Скачиваний:
29
Добавлен:
12.05.2015
Размер:
6.96 Mб
Скачать

Application Interfaces

runningSum = runningSum1 + runningSum2; runningCount = runningCount1 + runningCount2;

Oracle lets you register new aggregate functions by providing specific implementations for these primitive operations.

Application Interfaces

Oracle provides several facilities for using object datatypes in application programs:

SQL

PL/SQL

Pro*C/C++

OCI

OTT

JPublisher

JDBC

SQLJ

SQL

Oracle SQL data definition language provides the following support for object datatypes:

Defining object types, nested tables, and arrays

Specifying privileges

Specifying table columns of object types

Creating object tables

Oracle SQL data manipulation language provides the following support for object datatypes:

Querying and updating objects and collections

Manipulating REFs

See Also: Oracle9i SQL Reference for a complete description of SQL syntax

Object Datatypes and Object Views 13-17

Application Interfaces

PL/SQL

PL/SQL is a procedural language that extends SQL. It offers features such as packages, data encapsulation, information hiding, overloading, and exception handling. Most stored procedures are written in PL/SQL.

PL/SQL allows use from within functions and procedures of the SQL features that support object types. The parameters and variables of PL/SQL functions and procedures can be of user-defined types.

PL/SQL provides all the capabilities necessary to implement the methods associated with object types. These methods (functions and procedures) reside on the server as part of a user’s schema.

See Also: PL/SQL User’s Guide and Reference for a complete description of PL/SQL

Pro*C/C++

The Oracle Pro*C/C++ precompiler allows programmers to use object datatypes in C and C++ programs. Pro*C developers can use the Object Type Translator to map Oracle object types and collections into C datatypes to be used in the Pro*C application.

Pro*C provides compile time type checking of object types and collections and automatic type conversion from database types to C datatypes. Pro*C includes an EXEC SQL syntax to create and destroy objects and offers two ways to access objects in the server:

SQL statements and PL/SQL functions or procedures embedded in Pro*C programs

A simple interface to the object cache, where objects can be accessed by traversing pointers, then modified and updated on the server

See Also:

"OCI" on page 13-20

Pro*C/C++ Precompiler Programmer’s Guide for a complete description of the Pro*C precompiler

13-18 Oracle9i Database Concepts

Application Interfaces

Dynamic Creation and Access of Type Descriptions

Oracle provides a C API to enable dynamic creation and access of type descriptions. Additionally, you can create transient type descriptions, type descriptions that are not stored persistently in the DBMS.

The C API enables creation and access of LNOCIAnyData and LNOCIAnyDataSet.

The LNOCIAnyData type models a self descriptive (with regard to type) data instance of a given type.

The LNOCIAnyDataSet type models a set of data instances of a given type.

Oracle also provides SQL data types (in Oracle’s Open Type System) that correspond to these data types.

SYS.ANYTYPE corresponds to LNOCIType

SYS.ANYDATA corresponds to LNOCIAnyData

SYS.ANYDATASET corresponds to LNOCIAnyDataSet

You can create database table columns and SQL queries on such data.

The new C API uses the following terms:

Transient types - Type descriptions (type metadata) that are not stored persistently in the database.

Persistent types - SQL types created using the CREATE TYPE SQL statement. Their type descriptions are stored persistently in the database.

Self-descriptive data - Data encapsulating type information along with the actual contents. The ANYDATA type (LNOCIAnyData) models such data. A data value of any SQL type can be converted to an ANYDATA, which can be converted back to the old data value. An incorrect conversion attempt results in an exception.

Self-descriptive MultiSet - Encapsulation of a set of data instances (all of the same type), along with their type description.

See Also:

Oracle9i Application Developer’s Guide - Object-Relational Features

Oracle Call Interface Programmer’s Guide

Object Datatypes and Object Views 13-19

Application Interfaces

OCI

The Oracle call interface (OCI) is a set of C language interfaces to the Oracle server. It provides programmers great flexibility in using the server’s capabilities.

An important component of OCI is a set of calls to allow application programs to use a workspace called the object cache. The object cache is a memory block on the client side that allows programs to store entire objects and to navigate among them without round trips to the server.

The object cache is completely under the control and management of the application programs using it. The Oracle server has no access to it. The application programs using it must maintain data coherency with the server and protect the workspace against simultaneous conflicting access.

LNOCI provides functions to:

Access objects on the server using SQL

Access, manipulate and manage objects in the object cache by traversing pointers or REFs

Convert Oracle dates, strings and numbers to C data types

Manage the size of the object cache’s memory

Create transient type descriptions. Transient type descriptions are not stored persistently in the DBMS. Compatibility must be set to Oracle9i or higher.

LNOCI improves concurrency by allowing individual objects to be locked. It improves performance by supporting complex object retrieval.

LNOCI developers can use the object type translator to generate the C datatypes corresponding to a Oracle object types.

See Also: Oracle Call Interface Programmer’s Guide

OTT

The Oracle type translator (OTT) is a program that automatically generates C language structure declarations corresponding to object types. OTT facilitates using the Pro*C precompiler and the OCI server access package.

See Also:

Oracle Call Interface Programmer’s Guide

Pro*C/C++ Precompiler Programmer’s Guide

13-20 Oracle9i Database Concepts

Соседние файлы в папке Oracle selected docs