7.1.4 PL/SQL
블록에서 다른 프러시저,
함수 호출하기
SQL> CREATE
OR REPLACE PROCEDURE create_dept
(
2 p_deptno IN dept2.deptno%TYPE,
3 p_dname IN dept2.dname%TYPE,
4 p_loc IN dept2.loc%TYPE
5 )
6 IS
7 BEGIN
8
9 INSERT INTO dept2 values (
10 p_deptno,
11 p_dname,
12 p_loc);
13 END;
14 /
프로시저가 생성되었습니다.
SQL> DECLARE
2 plsql_block VARCHAR2(500);
3 new_deptno dept2.deptno%TYPE := 99;
4 new_dname dept2.dname%TYPE := 'SALES';
5 new_loc dept2.loc%TYPE :=
'GURODIGITAL';
6 BEGIN
7 -- PL/SQL 프로그램
호출
8 plsql_block := 'BEGIN
create_dept(:a, :b, :c); END;';
9
10 EXECUTE IMMEDIATE plsql_block
11 USING new_deptno, new_dname, new_loc;
12 END;
13 /
PL/SQL 처리가 정상적으로 완료되었습니다.
SQL> SELECT
* FROM DEPT2;
DEPTNO DNAME LOC
---------- --------------
-------------
10 ACCOUNTING
GURODIGITAL
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
99 SALES
GURODIGITAL