How can I insert a long string into a blob using an insert statement

oracleoracle-11g-r2

ORA-06502: PL/SQL: numeric or value error: raw variable length too long
ORA-06512: at "SYS.UTL_RAW", line 224

the datatype is BLOB

here's my insert statement

insert into system_value (type, version, id, date_created, date_modified, value )
values ( 0, 0, 0, ${liquibase.db.datatype.timestamp.value}, ${liquibase.db.datatype.timestamp.value},
    utl_raw.cast_to_raw('...really long string'))

Best Answer

It looks to me like the string you're passing in is too long for the UTL_RAW procedure you're trying to call. From the Oracle documentation:

There is an error if the sum of the lengths of the inputs exceeds the maximum allowable length for a RAW, which is 32767 bytes.

found here: http://docs.oracle.com/cd/E11882_01/appdev.112/e40758/u_raw.htm#ARPLS072

I think you may need to utilize the DBMS_LOB package. Documentation found here: http://docs.oracle.com/cd/B28359_01/appdev.111/b28419/d_lob.htm#BABDDFDH

HTH.