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

Data Access Overview

of related tasks. They are created and stored in compiled form in the database and can be run by a user or a database application.

Procedures and functions are identical, except that functions always return a single value to the user. Procedures do not return values.

Packages Packages encapsulate and store related procedures, functions, variables, and other constructs together as a unit in the database. They offer increased functionality (for example, global package variables can be declared and used by any procedure in the package). They also improve performance (for example, all objects of the package are parsed, compiled, and loaded into memory once).

Database Triggers Database triggers are PL/SQL, Java, or C procedures that run implicitly whenever a table or view is modified or when some user actions or database system actions occur. Database triggers can be used in a variety of ways for managing your database. For example, they can automate data generation, audit data modifications, enforce complex integrity constraints, and customize complex security authorizations.

Autonomous Blocks You can call autonomous transactions from within a PL/SQL block. When an autonomous PL/SQL block is entered, the transaction context of the caller is suspended. This operation ensures that SQL operations performed in this block (or other blocks called from it) have no dependence or effect on the state of the caller’s transaction context.

Java Overview

Java is an object-oriented programming efficient for application-level programs. Java has key features that make it ideal for developing server applications. These features include the following:

Simplicity--Java is a simpler language than most others used in server applications because of its consistent enforcement of the object model. The large, standard set of class libraries brings powerful tools to Java developers on all platforms.

Portability--Java is portable across platforms. It is possible to write platform-dependent code in Java, but it is also simple to write programs that move seamlessly across machines. Oracle server applications, which do not support graphical user interfaces directly on the platform that hosts them, also tend to avoid the few platform portability issues that Java has.

1-14 Oracle9i Database Concepts

Data Access Overview

Automatic Storage Management--The Java virtual machine automatically performs all memory allocation and deallocation during program execution. Java programmers can neither allocate nor free memory explicitly. Instead, they depend on the JVM to perform these bookkeeping operations, allocating memory as they create new objects and deallocating memory when the objects are no longer referenced. The latter operation is known as garbage collection.

Strong Typing--Before you use a Java variable, you must declare the class of the object it will hold. Java's strong typing makes it possible to provide a reasonable and safe solution to inter-language calls between Java and PL/SQL applications, and to integrate Java and SQL calls within the same application.

No Pointers--Although Java retains much of the flavor of C in its syntax, it does not support direct pointers or pointer manipulation. You pass all parameters, except primitive types, by reference (that is, object identity is preserved), not by value. Java does not provide C's low level, direct access to pointers, which eliminates memory corruption and leaks.

Exception Handling--Java exceptions are objects. Java requires developers to declare which exceptions can be thrown by methods in any particular class.

Security--The design of Java bytecodes and the JVM allow for built-in mechanisms to verify that the Java binary code was not tampered with. Oracle9i is installed with an instance of SecurityManager, which, when combined with Oracle database security, determines who can invoke any Java methods.

Standards for Connectivity to Relational Databases--JDBC and SQLJ enable Java code to access and manipulate data resident in relational databases. Oracle provides drivers that allow vendor-independent, portable Java code to access the relational database.

See Also: Chapter 14, "SQL, PL/SQL, and Java"

XML Overview

XML, eXtensible Markup Language, is the standard way to identify and describe data on the Web. It is a human-readable, machine-understandable, general syntax for describing hierarchical data, applicable to a wide range of applications, databases, e-commerce, Java, web development, searching, and so on.

The Oracle server includes the Oracle XML DB, a set of built-in high-performance XML storage and retrieval technologies. The XML DB fully absorbs the W3C XML data model into the Oracle server and provides new standard access methods for navigating and querying XML. You get all the advantages of relational database

Introduction to the Oracle Server 1-15

Data Access Overview

technology and XML technology at the same time. Key aspects of the XML database include the following:

A native datatype -- XMLType -- to store and manipulate XML. Multiple storage options (CLOB, decomposed object-relational) are available with XMLType, and DBAs can choose a storage that meets their requirements for fidelity to original, ease of query, ease of regeneration, and so on. With XMLType, you can perform SQL operations, such as queries and OLAP functions on XML data, as well as XML operations, such as XPath searches and XSL transformations, on SQL data. You can build regular SQL indexes or Oracle Text indexes on XMLType for high performance for a broad spectrum of applications.

Native XML generation provides built in SQL operators and supplied PL/SQL packages to return the results of SQL queries formatted as XML.

An XML repository provides foldering, access control, FTP and WebDAV protocol support with versioning. This enables applications to retain a file abstraction when manipulating XML data.

Complementing the XML Database is the Oracle XML Developer Kit, or XDK. XDK is a set of commonly used building blocks or utilities for development and runtime support. The Oracle XDK contains the basic building blocks for reading, manipulating, transforming, and viewing XML documents. To provide a broad variety of deployment options, the Oracle XDKs are available for Java, JavaBeans, C, C++, and PL/SQL. Oracle XDKs consist of XML Parsers, an XSLT Processor, XML Schema Processor, XML Class Generator, XML Transviewer Java Beans, XML SQL Utility, and XSQL Servlet.

Advanced Queuing (AQ) is the message queuing functionality of the Oracle database. With this functionality, message queuing operations can be performed similar to that of SQL operations from the Oracle database. Message queuing functionality enables asynchronous communication between applications and users on Oracle databases using queues. AQ offers enqueue, dequeue, propagation, and guaranteed delivery of messages, along with exception handling in case messages cannot be delivered. Message queuing takes advantage of XMLType for XML message payloads.

See Also:

Chapter 12, "Native Datatypes"

Oracle9i XML Database Developer’s Guide - Oracle XML DB

1-16 Oracle9i Database Concepts

Data Access Overview

Transactions Overview

A transaction is a logical unit of work that comprises one or more SQL statements run by a single user. According to the ANSI/ISO SQL standard, with which Oracle is compatible, a transaction begins with the user’s first executable SQL statement. A transaction ends when it is explicitly committed or rolled back by that user.

Note: Oracle9i is broadly compatible with the SQL-99 Core specification.

Consider a banking database. When a bank customer transfers money from a savings account to a checking account, the transaction can consist of three separate operations: decrease the savings account, increase the checking account, and record the transaction in the transaction journal.

Oracle must guarantee that all three SQL statements are performed to maintain the accounts in proper balance. When something prevents one of the statements in the transaction from running (such as a hardware failure), then the other statements of the transaction must be undone. This is called rolling back. If an error occurs in making any of the updates, then no updates are made.

Figure 1–2 illustrates the banking transaction example.

Introduction to the Oracle Server 1-17

Data Access Overview

Figure 1–2 A Banking Transaction

Transaction Begins

Decrement Savings Account

UPDATE savings_accounts

SET balance = balance - 500 WHERE account = 3209;

Increment Checking Account

UPDATE checking_accounts

SET balance = balance + 500 WHERE account = 3208;

Record in Transaction Journal

INSERT INTO journal VALUES (journal_seq.NEXTVAL, '1B' 3209, 3208, 500);

End Transaction

COMMIT WORK;

Transaction Ends

See Also: Oracle9i SQL Reference for information about Oracle’s compliance with ANSI/ISO standards

Commit and Roll Back Transactions

The changes made by the SQL statements that constitute a transaction can be either committed or rolled back. After a transaction is committed or rolled back, the next transaction begins with the next SQL statement.

Committing a transaction makes permanent the changes resulting from all SQL statements in the transaction. The changes made by the SQL statements of a transaction become visible to other user sessions’ transactions that start only after the transaction is committed.

1-18 Oracle9i Database Concepts

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