Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
32
Добавлен:
16.04.2013
Размер:
4.96 Mб
Скачать

Executing External Procedures with the CALL Statement

Do not call an external procedure directly. Instead, use the CALL statement to call the PL/SQL subprogram that published the external procedure. See "CALL Statement Syntax".

Such calls, which you code in the same manner as a call to a regular PL/SQL procedure or function, can appear in the following:

Anonymous blocks

Standalone and packaged subprograms

Methods of an object type

Database triggers

SQL statements (calls to packaged functions only).

Any PL/SQL block or subprogram executing on the server side, or on the client side, (for example, in a tool such as Oracle Forms) can call an external procedure. On the server side, the external procedure runs in a separate process address space, which safeguards your database. Figure 8–2 shows how Oracle Database and external procedures interact.

Figure 8–2 Oracle Database and External Procedures

Oracle Database

Oracle Server

 

External Process

Disk Storage

Process Execution

 

Execution

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

PL/SQL

 

 

 

DLL

 

 

 

 

 

 

Interpreter

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

PL/SQL Subprogram

 

 

Java Virtual

 

 

 

 

 

 

 

 

 

 

Machine

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Java Method

 

 

 

 

 

 

 

 

 

 

SQL

 

 

 

 

 

 

 

 

 

 

 

 

 

External C

 

 

 

 

 

 

Engine

 

 

 

 

 

 

 

 

 

 

 

 

Process

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Preconditions for External Procedures

Before calling external procedures, you should consider the privileges, permissions, and synonyms that exist in the execution environment.

8-34 Oracle Database Application Developer's Guide - Fundamentals

Executing External Procedures with the CALL Statement

Privileges of External Procedures

When external procedures are called through CALL specifications, they execute with definer's privileges, rather than invoker's privileges.

A program executing with invoker's privileges is not bound to a particular schema. It executes at the calling site and accesses database items (such as tables and views) with the caller's visibility and permissions. However, a program executing with definer's privileges is bound to the schema in which it is defined. It executes at the defining site, in the definer's schema, and accesses database items with the definer's visibility and permissions.

Managing Permissions

Note: You may need to set up the following data structures for certain examples to work:

CONNECT system/manager

GRANT CREATE ANY DIRECTORY to scott; CONNECT scott/tiger

CREATE OR REPLACE DIRECTORY bfile_dir AS '/tmp';

CREATE OR REPLACE JAVA RESOURCE NAMED "appImages" USING BFILE (bfile_dir,'bfile_audio');

To call external procedures, a user must have the EXECUTE privilege on the call specification and on any resources used by the procedure.

In SQL*Plus, you can use the GRANT and REVOKE data control statements to manage permissions. For example:

GRANT EXECUTE ON plsToJ_demoExternal_proc TO Public;

REVOKE EXECUTE ON plsToJ_demoExternal_proc FROM Public;

GRANT EXECUTE ON JAVA RESOURCE "appImages" TO Public;

GRANT EXECUTE ON plsToJ_demoExternal_proc TO Scott;

REVOKE EXECUTE ON plsToJ_demoExternal_proc FROM Scott;

See Also: Oracle Database SQL Reference

Creating Synonyms for External Procedures

For convenience, you or your DBA can create synonyms for external procedures using the CREATE [PUBLIC] SYNONYM statement. In the following example, your

Calling External Procedures 8-35

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