2
什么会导致以下行为打开它:不能使用dbms_lob.filopen打开的文件,但可以使用UTL_FILE
数据库11gR2的
declare
l_amt number := dbms_lob.lobmaxsize;
l_dst_loc clob;
l_dst_offset number := 1;
l_lang_ctx number := dbms_lob.default_lang_ctx;
l_src_loc bfile;
l_src_offset number := 1;
l_warning number;
begin
l_src_loc := bfilename('ODS_SERVER_DIRECTORY', '_CIVKD_ASU.CSV');
dbms_lob.createtemporary(l_dst_loc, true);
dbms_lob.fileopen(l_src_loc, dbms_lob.file_readonly);
dbms_lob.loadclobfromfile(l_dst_loc
,l_src_loc
,l_amt
,l_dst_offset
,l_src_offset
,dbms_lob.default_csid
,l_lang_ctx
,l_warning);
commit;
dbms_lob.fileclose(l_src_loc);
dbms_output.put_line(substr(l_dst_loc, 1, 200));
end;
/
ORA-22288: file or LOB operation FILEOPEN failed
.
ORA-06512: in "SYS.DBMS_LOB", line 805
ORA-06512: in line 31
22288. 00000 - "file or LOB operation %s failed\n%s"
*Cause: The operation attempted on the file or LOB failed.
*Action: See the next error message in the error stack for more detailed
information. Also, verify that the file or LOB exists and that
the necessary privileges are set for the specified operation. If
the error still persists, report the error to the DBA.
但是打开和使用UTL_FILE读时完全相同的文件成功。
declare
l_file utl_file.file_type;
l_regel varchar2(4000);
begin
l_file := utl_file.fopen('ODS_SERVER_DIRECTORY', '_CIVKD_ASU.CSV', 'R');
-- Haal de volgende regel op
utl_file.get_line(l_file, l_regel);
dbms_output.put_line(l_regel);
utl_file.fclose_all;
end;
所以它看起来文件是可用的,并可由数据库访问。
这是我们第一次遇到这个特定的错误,它是第一个11gR2实例之一,所以也许有11g我们不知道?
===更新8-6-2012 === 取得了一些进展。事实证明,目录对象指向共享驱动器。它是一个Windows服务器,Oracle作为本地系统运行。我一直认为在这种情况下无法从共享驱动器读取任何内容。显然在某些情况下,您可以使用utl_file但不使用dbms_lob。
仅仅因为你不应该使用UTL_FILE_DIR并不意味着你的DBA不会坚持它。 –
谢谢,这绝对是一个目录。一切都告诉我它应该工作,但它不是。最后的手段是重新启动整个服务器,但这是不可能的。 – Rene