日期:2014-05-16 浏览次数:21289 次
create or replace procedure pro_union_binary(recordid number) is cursor v_cursor is select * from tb_image_info where itemid = recordid order by ilineid; v_item v_cursor%rowtype; v_count integer default 0; v_ilineid integer default 0; v_sql varchar2(32767) default ''; v_characters clob; v_seq integer default 1; v_blob blob; warning integer; dest_offset1 integer := 1; src_offset1 integer := 1; lang_ctx INTEGER := DBMS_LOB.default_lang_ctx; begin select count(*) into v_count from tb_image_info where itemid = recordid; if v_count = 1 then return; end if; open v_cursor; loop fetch v_cursor into v_item; exit when v_cursor%notfound; if v_ilineid = 0 then v_ilineid := v_item.ilineid; end if; v_characters := v_characters || v_item.image; --获取已经得到的二进制文件流对应的十六进制字符串 if v_seq = v_count then if dbms_lob.getlength(v_characters) = 0 then return; end if; DBMS_LOB.createtemporary(v_blob, TRUE); DBMS_LOB.OPEN(v_blob, DBMS_LOB.lob_readwrite); DBMS_LOB.convertToBlob(v_blob, v_characters, DBMS_LOB.lobmaxsize, dest_offset1, src_offset1, DBMS_LOB.default_csid, lang_ctx, warning); v_sql := 'update tb_image_info set image0 = :1 where ilineid = :2'; execute immediate v_sql using v_blob, v_ilineid; end if; v_seq := v_seq + 1; end loop; end pro_union_binary;