Toad World® Forums

Writing to Blobs


#1

Continuation from “Writing to Clobs”:

Simple example how can we write to blobs:

function write2blob(rap_in in varchar2_list) return blob is
v_rap_out blob:=null;
begin

if rap_in.count > 0 then
    dbms_lob.CreateTemporary(v_rap_out,True);

for line in rap_in.first … rap_in.last loop
dbms_lob.append(v_rap_out,utl_raw.cast_to_raw(rap_in(line)));
end loop;

–dbms_lob.freetemporary(v_rap_out);
return v_rap_out;

else
    dbms_output.put_line('No data found');
    return null;
end if;

 
exception
    when others then
        dbms_lob.freetemporary(v_rap_out);
        raise;

end write2blob;

Regards Piter