189 8069 5689

oracleplsqlutl_file

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;
/

我们提供的服务有:成都网站设计、成都网站建设、微信公众号开发、网站优化、网站认证、黔西南州ssl等。为1000多家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的黔西南州网站制作公司


当前标题:oracleplsqlutl_file
本文链接:http://cdxtjz.cn/article/pisigo.html

其他资讯