set SERVEROUT on
DECLARE
tab_sql varchar2(4000);
tab_lob clob;
TYPE ddl_type IS REF CURSOR;
ddl_cur ddl_type;
type tab_ddl_type is record(
ddl_con clob
);
tab_ddl tab_ddl_type;
cursor tab_cur is select DISTINCT object_type,object_name,OWNER from dba_procedures where owner='FWPROD' ;
file utl_file.file_type;
clob_length number(20);
clob_part VARCHAR2(1024);
offset NUMBER := 1;
BEGIN
file := utl_file.fopen('DATA_PUMP_DIR', 'mes_procedure_ddl.log', 'ab');
for i in tab_cur loop
tab_sql := 'select dbms_metadata.get_ddl('''||i.object_type||''','''||i.object_name||''','||''''||i.owner||''') as ddl_con from dual';
DBMS_OUTPUT.PUT_LINE(tab_sql);
open ddl_cur for tab_sql;
FETCH ddl_cur INTO tab_ddl;
--DBMS_OUTPUT.PUT_LINE(tab_ddl.ddl_con);
clob_length := LENGTH(tab_ddl.ddl_con);
offset := 1;
LOOP
EXIT WHEN offset >= clob_length;
clob_part := DBMS_LOB.SUBSTR (tab_ddl.ddl_con, 1024, offset);
UTL_FILE.PUT_RAW(file, utl_raw.cast_to_raw(clob_part));
UTL_FILE.FFLUSH(file);
offset := offset + 1024;
END LOOP;
close ddl_cur;
END LOOP;
utl_file.fclose(file);
END;
/
相关文章
- 07-12plsql使用之debug
- 07-12plsql exist和in 的区别
- 07-12DM数据库使用UTL_FILE读写文件方法
- 07-12PLSQL转义字符
- 07-12PLSQL Developer激活码
- 07-12PLSQL中使用二维存储结构---二维数组
- 07-12UTL_FILE 包使用介绍
- 07-12UTL_FILE写入文件,文件用记事本打开不换行的问题
- 07-12PLSQL 的简单命令之三
- 07-12ORACLE 如何检查找出损坏索引 ( Corrupt Indexes )