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

Hiding PL/SQL Code with the PL/SQL Wrapper

DECLARE

TYPE Emplist IS VARRAY(100) OF NUMBER;

Empids EMPLIST := EMPLIST(7369, 7499, 7521, 7566, 7654, 7698);

TYPE Bonlist IS TABLE OF Emp_tab.sal%TYPE;

Bonlist_inst BONLIST;

BEGIN

Bonlist_inst := BONLIST(1,2,3,4,5);

FORALL i IN Empids.FIRST..empIDs.LAST

UPDATE Emp_tab SET Bonus = 0.1 * Sal

WHERE Empno = Empids(i)

RETURNING Sal BULK COLLECT INTO Bonlist;

FOR i IN Empids.FIRST..Empids.LAST LOOP

UPDATE Emp_tab Set Bonus = 0.1 * sal

WHERE Empno = Empids(i)

RETURNING Sal INTO BONLIST(i);

END LOOP;

END;

Without the bulk bind, PL/SQL sends a SQL statement to the SQL engine for each employee that is updated, leading to context switches that hurt performance.

Triggers

A trigger is a special kind of PL/SQL anonymous block. You can define triggers to fire before or after SQL statements, either on a statement level or for each row that is affected. You can also define INSTEAD OF triggers or system triggers (triggers on

DATABASE and SCHEMA).

See Also: Chapter 9, "Using Triggers"

Hiding PL/SQL Code with the PL/SQL Wrapper

You can deliver your stored procedures in object code format using the PL/SQL Wrapper. Wrapping your PL/SQL code hides your application internals. To run the PL/SQL Wrapper, enter the WRAP statement at your system prompt using the following syntax:

wrap INAME=input_file [ONAME=output_file]

See Also: PL/SQL User's Guide and Reference for complete instructions on using the PL/SQL Wrapper

7-20 Oracle Database Application Developer's Guide - Fundamentals

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