/******************************* VARCHAR2 형 Function ********************************/
CREATE OR REPLACE FUNCTION DSQL_CMD
(
P_SQL IN VARCHAR2 -- SQL COMMAND
) RETURN INTEGER
IS
/*
* PGM ID : DSQL_CMD
* TITLE :
* AUTHOR :
* DATE :
* VERSION :
* CONTENTS :
*/
V_RESULT INTEGER := NULL;
V_CUR INTEGER := NULL; -- DDL CURSOR
SQL_CMD VARCHAR2(32767) := NULL;
BEGIN
V_CUR := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(V_CUR, P_SQL, DBMS_SQL.NATIVE);
V_RESULT := DBMS_SQL.EXECUTE(V_CUR);
DBMS_SQL.CLOSE_CURSOR(V_CUR);
RETURN V_RESULT;
EXCEPTION
WHEN OTHERS THEN
RETURN 99;
END;
/******************************* COLB 형 Function ********************************/
CREATE OR REPLACE FUNCTION DSQL_CMD_CLOB
(
P_SQL IN CLOB -- SQL COMMAND
) RETURN INTEGER
IS
/*
* PGM ID : DSQL_CMD_CLOB
* TITLE :
* AUTHOR :
* DATE :
* VERSION :
* CONTENTS :
*/
V_ARRAY DBMS_SQL.VARCHAR2A;
V_CURNO NUMBER;
V_UB NUMBER;
V_RESULT INTEGER;
BEGIN
V_CURNO := DBMS_SQL.OPEN_CURSOR;
V_UB := CEIL(DBMS_LOB.GETLENGTH(P_SQL)/1000);
FOR IDX IN 1 .. V_UB LOOP
V_ARRAY(IDX) := DBMS_LOB.SUBSTR(P_SQL, 1000, (IDX-1)*1000+1);
END LOOP;
DBMS_SQL.PARSE(V_CURNO, V_ARRAY, 1, V_UB, FALSE, DBMS_SQL.NATIVE);
V_RESULT := DBMS_SQL.EXECUTE(V_CURNO);
DBMS_SQL.CLOSE_CURSOR(V_CURNO);
RETURN V_RESULT;
EXCEPTION
WHEN OTHERS THEN
RETURN 99;
END;
'전산Tip > Oracle' 카테고리의 다른 글
[ORACLE] Procedure Re-Compile (0) | 2010.06.01 |
---|---|
[ORACLE] DROP TABLE시 휴지통 파일 생성하지 않기 (0) | 2010.05.17 |
ORACLE EXCEPTION NAME (1) | 2010.05.07 |