Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Programming PL SQL.doc
Скачиваний:
3
Добавлен:
01.07.2025
Размер:
5.06 Mб
Скачать

20.5.2 Limitations of Oracle's Remote Invocation Model

With the Oracle software available at the time of this writing, there is no direct way for any PL/SQL program to directly use any of the following package constructs on a remote server:

  • Variables (including constants)

  • Cursors

  • Exceptions

This limitation applies not only to client PL/SQL calling the database server, but also to server-to-server RPCs.

The simple workaround for variables is to use "get-and-set" programs to encapsulate the data. In general, you should be doing that anyway, as it's an excellent programming practice.

The workaround for cursors is to encapsulate them with "open, fetch, and close" subprograms. For example, if you've declared a book_cur cursor in the specification of the book_maint package, you could put this corresponding package body on the server:

CREATE OR REPLACE PACKAGE BODY book_maint

AS

prv_book_cur_status BOOLEAN;

PROCEDURE open_book_cur IS

BEGIN

IF NOT book_maint.book_cur%ISOPEN

THEN

OPEN book_maint.book_cur;

END IF;

END;

FUNCTION next_book_rec

RETURN books%ROWTYPE

IS

l_book_rec books%ROWTYPE;

BEGIN

FETCH book_maint.book_cur INTO l_book_rec;

prv_book_cur_status := book_maint.book_cur%FOUND;

RETURN l_book_rec;

END;

FUNCTION book_cur_is_found

RETURN BOOLEAN

IS

BEGIN

RETURN prv_book_cur_status;

END;

PROCEDURE close_book_cur IS

BEGIN

IF book_maint.book_cur%ISOPEN

THEN

CLOSE book_maint.book_cur;

END IF;

END;

END;

Unfortunately, this approach won't work around the problem of using remote exceptions; the exception "datatype" is treated differently from true datatypes. Instead, you can use the RAISE_APPLICATION_ERROR procedure with a user-defined exception number between -20000 and -20999. See Chapter 6 for a discussion of how to write a good package to help your application manage this type of exception.

20.5.3 Client-Side pl/sql Libraries

Broadly speaking, PL/SQL lives in two major places on the client side:

  • In a reusable PL/SQL "library"

  • In the application module (form, report, etc.) itself

A library can contain any number of procedures, functions, and packages; it is a kind of "super-package" structure. The library construct is unique to Oracle's client-side tools, and using it properly bears some discussion. The first thing to realize is that, although PL/SQL code may reside in a lot of different places—as Table 20-4 shows—only libraries can contain PL/SQL that you can share among different client modules.

Table 20-4. Libraries and other file types on the client side that may contain PL/SQL

File extension

Expansion

Type of PL/SQL contained

.PLL

PL/SQL library

PL/SQL source, DIANA, and bytecode of procedures, functions, and packages

.PLX

PL/SQL library "executable"

Bytecode corresponding to the program units in the library

.PLD

PL/SQL library text

Optional readable text version of program units in the library

.FMB

Forms module binary

Any PL/SQL source code (and other source code) in an Oracle Forms module, but stored in a binary file along with DIANA and bytecode

.FMX

Forms module "executable"

Bytecode corresponding to any PL/SQL in the Oracle Forms module

.FMT

Forms module text

Optional text version of the Oracle Forms module; however, any PL/SQL appears only in hex

.RDF

Report definition file

Any PL/SQL that you've created in the Oracle Reports module, stored in a binary file along with DIANA and bytecode

.REP

Report runfile

Bytecode corresponding to any PL/SQL in the Oracle Reports module

.REX

Report text file

Optional text version of the Oracle Reports application, including readable PL/SQL source code

.MMB

Menu module binary

Any PL/SQL that you've created in the menu module, stored in a binary file along with DIANA and bytecode

.MMX

Menu module executable

Bytecode corresponding to any PL/SQL in the menu module

.MMT

Menu module text

Optional text version of menu module

Because PL/SQL libraries can dramatically improve the design and performance of your client-side applications, the next two sections present some of the concepts and non-obvious aspects of putting libraries to use.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]