put_raw 的时候超过了文件写入的限制,怎么解决?declare
lobloc blob;
buffer raw(2000);
amount int;
offset int:=1;
offset_size int:=2000;
handle utl_file.file_type;
begin
select photo into lobloc from lob_example2
where id=2;
amount:=dbms_lob.getlength(lobloc);
dbms_output.put_line(amount);
while (offset < amount) loop
dbms_lob.read(lobloc,offset_size,offset,buffer);
offset:=offset + offset_size;
handle:=utl_file.fopen('TT','a.jpg','w',offset_size);
utl_file.put_raw(handle,buffer);
dbms_output.put_line(offset);
utl_file.new_line(handle);
utl_file.fclose(handle);
end loop;
end ;
lobloc blob;
buffer raw(2000);
amount int;
offset int:=1;
offset_size int:=2000;
handle utl_file.file_type;
begin
select photo into lobloc from lob_example2
where id=2;
amount:=dbms_lob.getlength(lobloc);
dbms_output.put_line(amount);
while (offset < amount) loop
dbms_lob.read(lobloc,offset_size,offset,buffer);
offset:=offset + offset_size;
handle:=utl_file.fopen('TT','a.jpg','w',offset_size);
utl_file.put_raw(handle,buffer);
dbms_output.put_line(offset);
utl_file.new_line(handle);
utl_file.fclose(handle);
end loop;
end ;
解决方案 »
- 用户、数据库、表空间、实例这几个基本概念之间的对应关系
- Oracle 模糊查询问题
- 如何获取sql语句的执行情况
- oracle排序
- 一个简单的查询
- Oracle EBS,socket模式,客户端通过网页访问服务端,报文分析
- 如何将一个表中的字段数据导出到另一个表中字段中?
- 建表时出错:无法为表空间 MyTablespace 中的段创建INITIAL区
- 使用powerdesigner9.5对ORACLE9I数据库建模时,对象上的引号问题。
- 关于客户端连接Oracle服务器!急,在线等
- 求教这个连接数据库的方式怎么测试啊
- Oracle 10.2.0 实例经常自动断开,ora-00600.求救!!!
utl_file.put_raw好像要刷新一下缓存,不如写道一定程度也会抱错.
2. 在ORACLE 10g上,在打开文件时,UTL_FILE.FOPEN函数可带参数b,采用binary的方式处理文件,修复了这个BUG。
3. SQL:
1 declare
2 vblob blob;
3 vstart number:=1;
4 bytelen number := 32000;
5 len number;
6 my_vr raw(32000);
7 l_output utl_file.file_type;
8 begin
9 l_output := utl_file.fopen('TT', 'a.jpg', 'wb', 32760);
10 SELECT photo into vblob FROM lob_example2 where id = 2 and rownum =1;
11 len := DBMS_LOB.GETLENGTH(vblob);
12 dbms_output.put_line('Length of the Column : ' || to_char(len));
13 vstart := 1;
14 while (vstart < len) loop
15 dbms_output.put_line('vstart : ' || to_char(vstart));
16 DBMS_LOB.READ(vblob,bytelen,vstart,my_vr);
17 utl_file.put_raw(l_output,my_vr);
18 utl_file.fflush(l_output);
19 vstart := vstart + bytelen ;
20 end loop;
21 utl_file.fclose(l_output);
22 end ;
23 /