How can I insert into a BLOB column from an insert statement in sqldeveloper?

chris picture chris · Sep 20, 2011 · Viewed 119k times · Source

Is it possible to insert into a BLOB column in oracle using sqldeveloper?

i.e. something like:

insert into mytable(id, myblob) values (1,'some magic here');

Answer

Nicolas Filotto picture Nicolas Filotto · Jan 29, 2014

To insert a VARCHAR2 into a BLOB column you can rely on the function utl_raw.cast_to_raw as next:

insert into mytable(id, myblob) values (1, utl_raw.cast_to_raw('some magic here'));

It will cast your input VARCHAR2 into RAW datatype without modifying its content, then it will insert the result into your BLOB column.

More details about the function utl_raw.cast_to_raw