Oracle Clob 列导出到 .msg 文件
我已经成功创建了两个将 clob 数据导出到 .msg 文件的过程 - 但由于某种原因,所有 clob 数据都没有导出到文件 - 不知道该怎么做 - 任何帮助
Declare
Cursor c_emp_files
is
SELECT id, clob_content
FROM table;
Begin
for c in c_emp_files loop
clob_to_file('c:\temp\', 'F'||c.file_id||'.msg', c.clob_content);
end loop;
End;
create or replace PROCEDURE blob_to_file (i_dir IN VARCHAR2,
i_file_name IN VARCHAR2,
i_clob IN CLOB)
AS
l_file UTL_FILE.file_type;
l_buffer RAW (32767);
l_amount BINARY_INTEGER := 32767;
l_pos INTEGER := 1;
l_blob_len INTEGER;
BEGIN
l_blob_len := DBMS_LOB.getlength (i_clob);
l_file :=
UTL_FILE.fopen (i_dir,
i_file_name,
'WB',
32767);
WHILE l_pos < l_blob_len
LOOP
DBMS_LOB.read (i_clob,
l_amount,
l_pos,
l_buffer);
UTL_FILE.put_raw (l_file, l_buffer, TRUE);
l_pos := l_pos + l_amount;
END LOOP;
UTL_FILE.fclose (l_file);
EXCEPTION
WHEN OTHERS
THEN
IF UTL_FILE.is_open (l_file)
THEN
UTL_FILE.fclose (l_file);
END IF;
END blob_to_file;
我得到文件输出作为例外,但我不能无法打开文件 - 我猜它没有导出完整内容
I have managed to create two procedure for exporting clob data to .msg file - But for some reason all the clob data is not been exported to the file - Not sure what to do - Any help
Declare
Cursor c_emp_files
is
SELECT id, clob_content
FROM table;
Begin
for c in c_emp_files loop
clob_to_file('c:\temp\', 'F'||c.file_id||'.msg', c.clob_content);
end loop;
End;
create or replace PROCEDURE blob_to_file (i_dir IN VARCHAR2,
i_file_name IN VARCHAR2,
i_clob IN CLOB)
AS
l_file UTL_FILE.file_type;
l_buffer RAW (32767);
l_amount BINARY_INTEGER := 32767;
l_pos INTEGER := 1;
l_blob_len INTEGER;
BEGIN
l_blob_len := DBMS_LOB.getlength (i_clob);
l_file :=
UTL_FILE.fopen (i_dir,
i_file_name,
'WB',
32767);
WHILE l_pos < l_blob_len
LOOP
DBMS_LOB.read (i_clob,
l_amount,
l_pos,
l_buffer);
UTL_FILE.put_raw (l_file, l_buffer, TRUE);
l_pos := l_pos + l_amount;
END LOOP;
UTL_FILE.fclose (l_file);
EXCEPTION
WHEN OTHERS
THEN
IF UTL_FILE.is_open (l_file)
THEN
UTL_FILE.fclose (l_file);
END IF;
END blob_to_file;
I am getting file output as excepted but I couldn't open the file - I guess it is not exporting full content
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过一些朋友的帮助,我发现了以下内容:他们是 Oracle 中已经存在的程序 - 可以转换 Colb2file - 这在 Oracle 11g 中完美运行
Clob2file 过程
参考自链接
示例代码:
After some friends help I found the below: their is a procedure in place already in Oracle - which can convert Colb2file - This worked perfectly in Oracle 11g
Clob2file procedure
reference from link
Example code: