권한부여.
SQL> GRANT CREATE ANY TABLE TO 유저; SQL> GRANT EXECUTE ON DBMS_SQL TO 유저;
CREATE OR REPLACE PROCEDURE GITS.PIT_GENERATE_PLSQL
/***************************************************************************
PURPOSE ORACLE PL/SQL 문장을 입력 받아 실행한다.(Function Create)
REVISIONS:
Ver Date Author Description
--------- ---------- --------------- --------------------------------
1.0 2012-07-06 탑 1. Created this package.
***************************************************************************/
(
I_PLSQL_SYNTAX IN VARCHAR2
, I_REQUEST_USER_ID IN TIT_USER_MST.USER_ID%TYPE
, I_REQUEST_PROGRAM_ID IN TIT_PROGRAM_MST.PROGRAM_ID%TYPE
, O_ERROR_CD OUT VARCHAR2
, O_ERROR_MSG OUT VARCHAR2
)
AUTHID CURRENT_USER
IS
S_PROCESS_NAME VARCHAR2(50) := '[PIT_GENERATE_PLSQL]';
S_RECORD_COUNT NUMBER := 0;
ERROR01 EXCEPTION;
S_PLSQL_SYNTAX VARCHAR2(32767);
OPEN_CURSOR INTEGER;
EFFECTED_ROWS INTEGER;
BEGIN
/*********************************************************************
요청 사용자 ID Check
*********************************************************************/
BEGIN
SELECT COUNT(USER_SID)
INTO S_RECORD_COUNT
FROM TIT_USER_MST
WHERE USER_ID = I_REQUEST_USER_ID;
IF S_RECORD_COUNT = 0
THEN
O_ERROR_CD := 'ERROR';
O_ERROR_MSG := S_PROCESS_NAME||'Request User does not Exists.';
RAISE ERROR01;
END IF;
END;
/*********************************************************************
PL SQL 실행
*********************************************************************/
BEGIN
S_PLSQL_SYNTAX := '' || 'CREATE OR REPLACE ' || I_PLSQL_SYNTAX || '';
OPEN_CURSOR := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(OPEN_CURSOR, S_PLSQL_SYNTAX ,DBMS_SQL.NATIVE);
EFFECTED_ROWS := DBMS_SQL.EXECUTE(OPEN_CURSOR);
DBMS_SQL.CLOSE_CURSOR(OPEN_CURSOR);
--EXECUTE IMMEDIATE 'CREATE OR REPLACE '|| I_PLSQL_SYNTAX;
O_ERROR_CD := 'OK';
O_ERROR_MSG := S_PROCESS_NAME || ' was executed.';
END;
/*********************************************************************
오류 처리
*********************************************************************/
EXCEPTION
WHEN ERROR01 THEN
RETURN;
WHEN OTHERS THEN
RAISE;
RETURN;
END PIT_GENERATE_PLSQL;
/
오라클 커서(Oracle cursor) 관련 내용 [출처] 오라클 커서(Oracle cursor) 관련 내용|작성자 어린나무 (0) | 2012.08.08 |
---|---|
Maximum open cursor error에 관해 (0) | 2012.08.08 |
Invalid 한 package 찾아 recompile (0) | 2012.07.16 |
오라클 패키지의 마법을 풀어봅시다. 2편 (0) | 2012.07.16 |
오라클 패키지의 마법을 풀어봅시다. 1편 (0) | 2012.07.16 |