you can use bfile datatype or clob to store large text
可以utl_file包,需要先设置utl_file_dir参数
可以给我一个例程吗?utl_file_dir参数如何设置?
我只给你一个写的例子,别的还是自己去查资料 1、修改init.ora文件,设置utl_file_dir参数 如utl_file_dir='/ora01/test/' 2、建立如下过程 create or replace procedure sp_test_write_file (text_content in varchar2) is file_handle utl_file.file_type; begin --open file file_handle:=utl_file.fopen(location=>'/ora01/test/',filename=>'My_File.txt',open_mode=>'W'); --write file utl_file.put_line(file_handle,text_content); --close file utl_file.fclose(file_handle); exception when others then raise; end sp_test_write_file; ---------------------------- 现场写的,没有测试,主要是给你思路,具体的资料还是自己去查,oracle的帮助文档上说的很明白.
PROCEDURE create_file (loc_in IN VARCHAR2, file_in IN VARCHAR2, line_in IN VARCHAR2 := NULL) IS file_handle UTL_FILE.FILE_TYPE; BEGIN /* || Open the file, write a single line and close the file. */ file_handle := UTL_FILE.FOPEN (loc_in, file_in, 'W'); IF line_in IS NOT NULL THEN UTL_FILE.PUT_LINE (file_handle, line_in); ELSE UTL_FILE.PUT_LINE (file_handle, 'I make my disk light blink, therefore I am.'); END IF; UTL_FILE.FCLOSE (file_handle); END;
1、修改init.ora文件,设置utl_file_dir参数
如utl_file_dir='/ora01/test/'
2、建立如下过程
create or replace procedure sp_test_write_file
(text_content in varchar2)
is
file_handle utl_file.file_type;
begin
--open file
file_handle:=utl_file.fopen(location=>'/ora01/test/',filename=>'My_File.txt',open_mode=>'W');
--write file
utl_file.put_line(file_handle,text_content);
--close file
utl_file.fclose(file_handle);
exception
when others then
raise;
end sp_test_write_file;
----------------------------
现场写的,没有测试,主要是给你思路,具体的资料还是自己去查,oracle的帮助文档上说的很明白.
如果你保存文件内容到字段,用c读取,保存到lob字段也是很好的。
(loc_in IN VARCHAR2, file_in IN VARCHAR2, line_in IN VARCHAR2 := NULL)
IS
file_handle UTL_FILE.FILE_TYPE;
BEGIN
/*
|| Open the file, write a single line and close the file.
*/
file_handle := UTL_FILE.FOPEN (loc_in, file_in, 'W');
IF line_in IS NOT NULL
THEN
UTL_FILE.PUT_LINE (file_handle, line_in);
ELSE
UTL_FILE.PUT_LINE
(file_handle, 'I make my disk light blink, therefore I am.');
END IF;
UTL_FILE.FCLOSE (file_handle);
END;