You are on page 1of 9

Developing Internet Applications with the Oracle® Call

Interface: The Complete Solution for Middle-Tiered


Application Development
An Oracle Technical White Paper
February 1999
INTRODUCTION

The Oracle Call Interface is an application programming interface (API) that allows an application
developer to access the Oracle database server and control all phases of SQL execution. The Oracle
Call Interface provides a library of standard database access and retrieval functions as a dynamic
runtime library that can be linked into an application eliminating the need to embed SQL or
PL/SQL™ within application programs. The Oracle Call Interface supports the datatypes, calling
conventions, syntax and semantics of a third generation language. In Oracle8™, the Oracle Call
Interface provided significantly improved application performance and scalability, a consistent
interface for session and transaction management in two-tier and multi-tier environments, and
comprehensive support for application development using Oracle8 object features.

In Oracle8i™, the Oracle Call Interface has added functionality targeted towards Internet application
development. There are two significant requirements that drive Internet applications — scalability
and response time. Web site developers need the flexibility to quickly scale-up the capacity of their
site to support the needs of a large number of users and respond quickly to their queries. The
Oracle8i version of the Oracle Call Interface is the most powerful and flexible programming interface
available — designed for building middle-tier Internet applications.

The paper is organized into the following sections.

• The Oracle Call Interface section of the paper describes the most important features of the Oracle Call
Interface in Oracle8i.

• Shared Oracle Call Interface explains how this feature allows processes and threads to share SQL text
and metadata allowing applications to scale easily.

• Asynchronous Event Notification describes the benefits of the new asynchronous notification of system
and database events using the Oracle Call Interface and how it can be used for incorporating push
technology in Internet applications.

• Group Name Concept describes how a group name can be used to pool a set of connections to service a
large number of users in an application server.

• Callback Registration Feature allows applications developed using the Oracle Call Interface to extend
the interface and connect to and interoperate with non-Oracle data-sources.

• Additional Performance Improvements describes several areas where performance has been
significantly improved.

Developing Internet Applications with the Oracle Call Interface 2


February 1999
THE ORACLE CALL INTERFACE

Oracle Call Interface is a third-generation language call-level interface to the Oracle database
that provides application developers with the greatest degree of control over multi-tiered
application development.

• Third Generation Language  The Oracle Call Interface supports the datatypes, calling conventions,
syntax and semantics of the third generation language, eliminating the need to embed SQL
statements or PL/SQL blocks in the 3GL program.

• Call-Level Interface  The Oracle Call Interface is a native procedure/function call-level application
programming interface that provides a library of standard database access and retrieval functions
that can be used in creating applications. These function calls are provided in the form of a
dynamic runtime library which links into the application.

• Greatest Control Over Program Execution  The function calls provided by the Oracle Call Interface
offers the developer the greatest degree of control over session, transaction management, and SQL
statement processing. The Oracle Call Interface, provides a highly tunable interface to the
database; a feature sophisticated developers will appreciate.

SHARED ORACLE CALL INTERFACE: ENABLES APPLICATION SCALABILITY

In Oracle7™, the Oracle Call Interface enabled database scalability through the use of shared cursors.
In Oracle8i, the Oracle Call Interface allows application processes to share SQL text and metadata
(the bind and describe information associated with the SQL statements). This feature provides
scalability for the middle-tier application servers. The Oracle Call Interface is designed to meet the
needs of developers creating application server software for servicing multiple Internet clients in a
multi-threaded, multi-process environment. These application servers respond to database access
requests in e-commerce transactions or web page requests, and can benefit from the shared Oracle
Call Interface mode by sharing data structures between applications. This allows them to be more
efficient by reducing the memory usage per process.

Oracle8i Oracle Call Interface features:

• Enables the creation of and connection to a named shared memory segment by a set of cooperating
processes and/or threads.

• Allows processes to share SQL text, bind and describe information.

• Provides opaque sharing of Oracle Call Interface structures using handles, allowing applications to
be shielded from underlying data structure changes in the future.

Developing Internet Applications with the Oracle Call Interface 3


February 1999
A common scenario where this feature has great applicability is when several instances of the same
application are running on the same machine to service multiple clients. Each of these instances may
be executing identical SQL statements, but differentiated by different bind values. Without using
the shared Oracle Call Interface feature, each execution of the query using an Oracle Call Interface
statement handle will require its own memory for storing the metadata. Thus, the total amount of
memory required would be roughly equal to the product of the number of statements being executed
in all the processes combined, and the memory required for each statement handle. Using the new
shared Oracle Call Interface feature allows a large part of the common memory in a statement handle
to be shared among all the processes executing the same statement. Thus, the total amount of
memory in all the processes combined, will significantly decrease for the same number of processes.
Also, the memory requirement per statement handle will be much smaller as the number of
statements increases. The applications that will benefit most significantly would be SQL drivers and
other middle-tiered applications while those that will benefit least are small applications which
execute single queries non-concurrently.

Example Usage

Consider a multi-tier Internet application where the clients (browsers) submit HTTP requests to the
application. The application architecture consists of a listener/dispatcher that receives an HTTP
request. It uses its routing policy and sends the request to one of the server processes, which in turn
decodes the HTTP request, and decides if it needs to access a database to generate a HTML page.
The application server or the middle-tier is usually made up of these processes and/or threads which
contain extensive SQL execution logic that define the application.

For example, an HTTP request for weather related information for a given city on a given day, could
return the same information in response to queries executed by multiple users. The example code
shown below is an SQL query that can be used to satisfy a request to obtain weather information for
five cities on any given day. It uses bind variables to make the SQL much more shareable and hence
scaleable on the client and the server.

SELECT city, ar_code, precip_code, sky_code FROM weather WHERE


day = :today and city IN (:city1, :city2, :city3, :city4,
:city5) ORDER by city

Developing Internet Applications with the Oracle Call Interface 4


February 1999
The above query is executed by all processes/threads that receive HTTP requests from end-users to
SQL queries, returning results in HTML. Each process or thread has a separate statement handle that
it executes in its own process or thread to get the result set. The statement handle internally points
to a single copy of the SQL text and the same copy of the bind meta-data information for the
bind variables

(:today, :city1, :city2, :city3, :city4, :city5)

and to the shared data describing information for all the columns

(city, ar_code, precip_code, sky_code).

This results in large memory savings, potentially several hundred bytes per instance of similar SQL
queries in the middle-tier.

Benchmark results run within Oracle indicate that in select statements involving 100 columns, use of
this feature can result in memory savings of up to 22 percent.

ASYNCHRONOUS EVENT NOTIFICATION: ALLOWS DEPLOYMENT OF PUSH-PULL


TECHNOLOGY

In Oracle8i, extensive support has been added to define and create system user-defined events, and
register subscriptions to, and receive notification about their occurrence. Applications need to use
SQL to create and define events and Oracle Call Interface to subscribe to and receive notification of
their occurrence. Used in conjunction with Advanced Queues, the event notification feature
introduces a powerful push-pull model of information dissemination that enables Internet commerce
and workflow applications to be built using the Oracle8i server.

In Oracle8, clients had to use traditional polling techniques to check for published messages. In
Oracle8i, the new publish/subscribe feature eliminates the need for polling messages and uses the
Oracle Call Interface for registering events of interest and a callback notification. This allows the
database to be used to serve personalized information to end-user applications, using a "push"
technology. We allow clients to register interest in database events and also receive notifications
when such events are triggered in the system.

Developing Internet Applications with the Oracle Call Interface 5


February 1999
Any client that is interested in registering for notifications uses a handle of the form Oracle Call
Interface Subscription. Calls are exposed to the client that enable them to register for subscriptions of
interest and post to subscriptions.

Application servers can use the events and asynchronous notification mechanism to monitor events
like startup, shutdown, logon and logoff. Using this feature, applications can monitor for these
events and can smoothly go online/off-line without having to poll or handle abrupt errors.

NAMED POOLED CONNECTIONS

In Oracle8, the Oracle Call Interface allowed applications to create multiple sessions per connection
that could be migrated over connections. Using this feature, application servers could support a large
number of users over a small number of connections and in the process customize the application for
load balancing, scheduling, and high availability. However, in Oracle8, sessions were owned by the
process that created the session. This restricted the availability of the session to the lifetime of the
parent process. Oracle8i extends the ownership of session to a group of named connections, allowing
applications to dynamically alter the set of pooled connections based on the load or
application characteristics.

The Oracle Call Interface also extends session sharing beyond the process space. Using the shared
Oracle Call Interface mode or the Get Attribute call, a user handle can be cloned across process
boundaries enabling user requests to be redirected to different processes according to the load profile.

This feature allows Internet applications to be shared among several users based on some policy. For
example, with the increase in the availability of professionally managed datacenters and outsourcing
of operations, it is possible to run a large Oracle application like the Oracle® Human Resources
package to service multiple clients. This is the concept of rentable applications. In such scenarios,
business contracts might dictate a guarantee that requires certain levels of service for the paying
customers. It might also dictate a policy of security that require the client identity to be tracked all
the way into the database for audit purposes. In such scenarios, using a group name to identify a pool
of connections and actual sessions (identifying the real user of this pool) multiplexed into these pools
for each paying customer is an extremely powerful way of enforcing security and service level policies.

For example, consider Acme Corporation with 50 potential users, Architects Corporation with 100
potential users and Sunshine Tech Corporation with 1000 employees that have outsourced their

Developing Internet Applications with the Oracle Call Interface 6


February 1999
datacenters to the service provider Rent-Me. Each company requires different levels of services. The
service level agreement with Acme will allow five concurrent processes to service up to 25 users and
then additional process to be created at a premium for every five users. The agreement with
Architects will allow ten concurrent connections to the database to service all of its users. Finally, the
agreement with Sunshine Tech will allow up to 100 dedicated connections to the database for all of
its users and more, if required, to maintain a minimum level of service. The datacenter’s application
can now service these clients with pools of connections identified by Acme, Architects, and Sunshine
Tech such that they fulfill the business contract of providing guaranteed levels of services and security
which would not have been possible using other techniques. As additional users connect to and
disconnect from the application, connections and sessions can be created or moved dynamically
between the groups using a previously agreed upon service level policy.

CALLBACK REGISTRATION ON ORACLE CALL INTERFACE FUNCTIONS

Application developers can register callbacks which are invoked at the entry and exit of each Oracle
Call Interface function. This allows application developers to add a variety of features including
tracing, debugging, or other user-specific processing. Vendors developing applications that connect
to multiple databases can use this feature to reduce their application programming efforts. They can
develop applications leveraging the Oracle Call Interface and using the callbacks to connect to other
databases using ODBC. This makes application development and maintenance easier while
guaranteeing fast execution and native access to the Oracle database.

MISCELLANEOUS PERFORMANCE IMPROVEMENTS

There are several areas where performance has been significantly improved. While some of these
features are transparent to the end-user, others require a small amount of re-coding of their
application to make use of these new features.

Transparent Performance Improvements

All rowids returned for SELECT for UPDATE: Pre-fetching or array fetch now returns rowids of all
rows selected for update. This allows developers to batch rowid fetches followed by array updates

Developing Internet Applications with the Oracle Call Interface 7


February 1999
using rowids. This results in significant performance improvements, as fewer round trips are
required for updates.

Enhanced Fetch  Query results are returned using less CPU time on the client and the server,
resulting in shorter elapsed time due to significant optimizations in the protocol.

New Features

Returning an array of errors for an array of Data Manipulation Language (DML) operations: Array
operations on DMLs was supported in the Oracle Call Interface before Oracle8i.
This allows users to execute DML commands and to operate on multiple rows in one round trip using
an array of bind values. However, when there is an error, the processing of the array stops at the
iteration causing the error. This could potentially result in multiple round trips and performance
degradation. In Oracle8i, all errors are batched and returned allowing all rows to be processed in one
round trip.

Non-Blocking Oracle Call Interface  Applications operating in this mode submit calls to the Oracle
server and receive control back immediately thereby improving their responsiveness. While the
server is processing the call, applications can perform other tasks on other connections or react to
external events. The application needs to periodically check for the completion of its request. This
functionality is especially valuable in graphical applications where the source and the order of user
events are unknown. By increasing the number of connections that the server can support efficiently,
and improving the responsiveness to clients, the non-blocking mode substantially enhances the
performance and scalability of the application.

As a result of all the above mentioned improvements, Oracle Call Interface applications exhibit
significantly better performance and scalability in Oracle8i.

Oracle8i is a significant release with substantial new functionality added to the Oracle Call Interface
for developing scalable, fast Internet applications. Several new features have been added, including
sharing of the Oracle Call Interface for scalability, asynchronous event notification for incorporating
push technology, group name concept and callback registration for simplifying applications support
for multiple databases.

Developing Internet Applications with the Oracle Call Interface 8


February 1999
Oracle Corporation
World Headquarters
500 Oracle Parkway
Redwood Shores, CA 94065
U.S.A.

Worldwide Inquiries:
+1.650.506.7000
Fax +1.650.506.7200
http://www.oracle.com/

Copyright © Oracle Corporation 1999


All Rights Reserved

Oracle is a registered trademark, and PL/SQL, Oracle8, Oracle8i,


and Oracle7 are trademarks of Oracle Corporation. All other
company and product names mentioned are used for
identification purposes only and may be trademarks of their
respective owners.

This document is provided for informational purposes only, and


the information herein is subject to change without notice.
Please report any errors herein to Oracle Corporation. Oracle
Corporation does not provide any warranties covering and
specifically disclaims any liability in connection with this
document.