ORA-29287: 最大行大小无效 ORA-06512: 在 “SYS.UTL_FILE“,

执行存储过程export_to_csv时报错:

SQL> begin
  2  export_to_csv('MYDIR');
  3  end;
  4  /
begin
*1 行出现错误:
ORA-29287: 最大行大小无效
ORA-06512: 在 "SYS.UTL_FILE", line 41
ORA-06512: 在 "SYS.UTL_FILE", line 478
ORA-06512: 在 "C##A.EXPORT_TO_CSV", line 29
ORA-06512: 在 line 2

1.查看存储过程创建时的第29行:
CSV_OUTPUT := UTL_FILE.FOPEN(P_DIR, OUT_FILE_NAME, 'W', MAX_LINE);

查询得知,使用了UTL_FILE 写超过32k的数据查询会报错:

CAUSE UTL_FILE.PUT has been used to write a CLOB data of size more than 32KB without flushing the buffer.
While writing into an ASCII file, the buffer will be flushed only after new line character is encountered. >If a new line character is not written before closing, then CLOSE() does this.
However if the current buffer exceeds the maximum allowed for a line in an ASCII file then CLOSE() raises this write error.

SOLUTION:

Open the file in ‘wb’ mode instead of ‘w’ mode.
Use UTL_FILE.PUT_RAW instead of UTL_FILE.PUT

CSV_OUTPUT := UTL_FILE.FOPEN(P_DIR, OUT_FILE_NAME, 'W', MAX_LINE);
改为

CSV_OUTPUT := UTL_FILE.FOPEN(P_DIR, OUT_FILE_NAME, 'wb', 32767);
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值