create table user_m
(
userid varchar2(10),
photo blob
);
procedure get_img(vuserid varchar2) is
vblob blob;
buffer raw(32000);
buffer_size integer := 32000;
offset integer := 1;
length number;
begin
owa_util.mime_header('image/gif');
select photo into vblob from user_m where userid = vuserid;
length := dbms_lob.getlength(vblob);
while offset
dbms_lob.read(vblob, buffer_size, offset, buffer);
htp.prn(utl_raw.cast_to_varchar2(buffer));
offset := offset + buffer_size;
end loop;
exception
when others then
htp.p(sqlerrm);
end;
解释:
在配置好pl/sql网关后,就可以调用这个存储过程例如:get_img?vuserid=1000
这里用到blob字段类型和对blob进行read操作的dbms_lob.read,以及在浏览器中
显示过程htp.prn,owa_util.mime_header('image/gif')这个过程提示告诉浏览器
显示的是一个图片。