Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to insert an image to a blob field in 12c

963732Aug 13 2014 — edited Aug 16 2014


Hi,

I am migrating my postgresql database to oracle 12c, I have a table which stores images in one of the columns, I am using bytea data type in postgresql and have a function with which I insert and update the images, here is the function from postgresql :

<code>

create or replace function bytea_import(p_path text, p_result out bytea)
                   language plpgsql as $$
declare
  l_oid oid;
  r record;
begin
  p_result := '';
  select lo_import(p_path) into l_oid;
  for r in ( select data
             from pg_largeobject
             where loid = l_oid
             order by pageno ) loop
    p_result = p_result || r.data;
  end loop;
  perform lo_unlink(l_oid);
end;$$;

</code>

Example : insert into my_table(bytea_data) select bytea_import('/my/file.name');

I am looking for solution to do that in oracle 12c.

Many thanks for your help !!

Terry

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 13 2014
Added on Aug 13 2014
10 comments
20,450 views