Utl_file fseek 函数给出具有较大绝对偏移量的错误?
我必须编写一个程序,使用 fseek 从特定位置读取数据。 我必须逐行读取数据,并且在特定行中我必须使用 fseek 来读取数据。 但是当我使用fseek并且absolute_offset尺寸很大(比文件大小小一点)时,它会给出这个错误,
ORA-29284: file read error
ORA-06512: at "SYS.UTL_FILE", line 219
ORA-06512: at "SYS.UTL_FILE", line 1145
ORA-06512: at line 15"
但是使用小的absolute_offset值(例如4000范围)可以正常工作并选择数据。 第 15 行,我使用 fseek 给出错误。
DECLARE
lv_utl UTL_FILE.FILE_TYPE;
v_buff VARCHAR2(2000);
l_exists boolean;
l_block VARCHAR2(2000);
l_file_length number;
v_line varchar2(5000);
BEGIN
UTL_FILE.fgetattr('/d04/data/edi/inbound','POO0001.dat',l_exists,l_file_length,l_block);
lv_utl := UTL_FILE.FOPEN('/d04/data/edi/inbound','POO0001.dat','R');
--utl_file.get_line(lv_utl,v_line,50);
--dbms_output.put_line(v_line);
--l_file_length:=length();
dbms_output.put_line(l_file_length);
utl_file.fseek(lv_utl,1261061);
utl_file.get_line(lv_utl,v_buff,100);
dbms_output.put_line(v_buff);
--lv_msg_txt := 'empno ename job manager hiredate commission salary department_no';
--UTL_FILE.PUT_LINE(lv_utl,lv_msg_txt);
--UTL_FILE.PUT_LINE(lv_utl,'------------------------------------------------------------------------------------');
--UTL_FILE.PUT_LINE(lv_utl,' ');
--UTL_FILE.FCLOSE(lv_utl);
END;
I have to make a program that will use fseek to read data from pirticular position.
i have to read data line by line,and in pirticular line i have to use fseek to read data.
But when i am using fseek and absolute_offset is of big size (little bit less then file size),it gives out this error
ORA-29284: file read error
ORA-06512: at "SYS.UTL_FILE", line 219
ORA-06512: at "SYS.UTL_FILE", line 1145
ORA-06512: at line 15"
but with small absolute_offset value like 4000 range works properly and picks data.
Line no 15 where i am using fseek giving error.
DECLARE
lv_utl UTL_FILE.FILE_TYPE;
v_buff VARCHAR2(2000);
l_exists boolean;
l_block VARCHAR2(2000);
l_file_length number;
v_line varchar2(5000);
BEGIN
UTL_FILE.fgetattr('/d04/data/edi/inbound','POO0001.dat',l_exists,l_file_length,l_block);
lv_utl := UTL_FILE.FOPEN('/d04/data/edi/inbound','POO0001.dat','R');
--utl_file.get_line(lv_utl,v_line,50);
--dbms_output.put_line(v_line);
--l_file_length:=length();
dbms_output.put_line(l_file_length);
utl_file.fseek(lv_utl,1261061);
utl_file.get_line(lv_utl,v_buff,100);
dbms_output.put_line(v_buff);
--lv_msg_txt := 'empno ename job manager hiredate commission salary department_no';
--UTL_FILE.PUT_LINE(lv_utl,lv_msg_txt);
--UTL_FILE.PUT_LINE(lv_utl,'------------------------------------------------------------------------------------');
--UTL_FILE.PUT_LINE(lv_utl,' ');
--UTL_FILE.FCLOSE(lv_utl);
END;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在我的环境中运行了这个并且也弹出了这个。奇怪的是,如果我在 FOPEN 上指定最大行长度,它似乎可以正常工作。
不工作,但
工作完美。我对此没有任何理由,但它确实看起来像一个错误。
作为解决方法,您可能需要尝试使用
BFILE
来尝试使用DBMS_LOB
包。I ran this in my environment and also had this pop up. Oddly, if I specify a maximum line lengh on
FOPEN
it seems to work correctly.doesn't work, but
works perfectly. I have no justification for this, but it sure looks like a bug.
As a work-around, you may want to try the
DBMS_LOB
package usingBFILE
s instead.我过去也遇到过这种情况。
最大行大小为 1024,除非在对 FOPEN 的调用中指定(正如您在上面的第二个示例中所做的那样(使用 5000)。
因此 Oracle 会争论 - 这是预期的行为,而不是错误。
http://docs.oracle.com/cd/B19306_01/appdev .102/b14258/u_file.htm
I have encountered this in the past.
Max Line size is 1024, unless specified in the call to FOPEN (as you have done so in second example above (with 5000).
So Oracle would argue - it is expected behaviour, rather than a bug.
http://docs.oracle.com/cd/B19306_01/appdev.102/b14258/u_file.htm