Теория для лабораторной работы №4 - "PL/SQL – процедурное расширение языка SQL", страница 6

Для встраивания инструкции CREATE PACKAGE BODY в программу Oracle Precompiler, вы должны закончить инструкцию ключевым словом END-EXEC с последующим разделителем встроенного SQL для определённого языка.

 

Пример.

Эти инструкции SQL создают тело пакета EMP_MGMT:

CREATE PACKAGE BODY emp_mgmt AS

         tot_emps  NUMBER;

          tot_depts NUMBER; 

          FUNCTION hire(ename VARCHAR2, job VARCHAR2, mgr NUMBER,

                                          sal NUMBER, comm NUMBER, deptno NUMBER)

                          RETURN NUMBER IS

                            new_empno NUMBER(4);

                          BEGIN

                            SELECT empseq.NEXTVAL

                                          INTO new_empno

                                          FROM DUAL;

                            INSERT INTO emp

                                          VALUES (new_empno, ename, job, mgr, sal, comm, deptno, 

                                          tot_emps := tot_emps + 1;

                                          RETURN(new_empno);

                          END;

          FUNCTION create_dept(dname VARCHAR2, loc VARCHAR2)

            RETURN NUMBER IS

                                          new_deptno NUMBER(4);

                          BEGIN

                            SELECT deptseq.NEXTVAL

                                          INTO new_deptno

                                          FROM dual;

                            INSERT INTO dept

                                          VALUES (new_deptno, dname, loc);

                            tot_depts := tot_depts + 1;

                            RETURN(new_deptno);

                          END;

          PROCEDURE remove_emp(empno NUMBER) IS