39

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');
Nicolas Filotto
  • 43,537
  • 11
  • 94
  • 122
chris
  • 36,094
  • 53
  • 157
  • 237

3 Answers3

57

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

Nicolas Filotto
  • 43,537
  • 11
  • 94
  • 122
52

Yes, it's possible, e.g. using the implicit conversion from RAW to BLOB:

insert into blob_fun values(1, hextoraw('453d7a34'));

453d7a34 is a string of hexadecimal values, which is first explicitly converted to the RAW data type and then inserted into the BLOB column. The result is a BLOB value of 4 bytes.

Codo
  • 75,595
  • 17
  • 168
  • 206
  • 10
    Unfortunately this won't work if the BLOB is greater than 2000 bytes - because there is a limitation in Oracle that a char constant can't be greater than 4000 characters. – Tobias Liefke Mar 11 '16 at 09:57
-2
  1. insert into mytable(id, myblob) values (1,EMPTY_BLOB);
  2. SELECT * FROM mytable mt where mt.id=1 for update
  3. Click on the Lock icon to unlock for editing
  4. Click on the ... next to the BLOB to edit
  5. Select the appropriate tab and click open on the top left.
  6. Click OK and commit the changes.