SQLTeam.com | Weblogs | Forums

Inserting files into a BLOB column (Oracle)?


I'm using an automated tool that's fetching the email attachments (mostly docx files) and saving them into a folder and a variable within the tool. Now I need to figure out a way to insert the files from that variable into the BLOB column of my table.

For example

INSERT INTO mytable ( column1 , column2 , BLOB_COLUMN)
VALUES (value1, value2, to_blob('%VARIABLE_CONTAINING_DOCX_FILE%' ));

value1 and value2 are text values and they are succesfully inserted into the table.

to_blob obviously didn't work, so I tried with RAWTOHEX and it worked but the file I exporeted from the BLOB column was corrupted since RAWTOHEX is not being used for BLOBs. Does anyone have a solution for this? What function should I use?

I found lot of solutions including a procedure and a directory but since I'm using this tool, I alredady have the files saved into a directory(variable) so my only options seems to be the INSERT INTO statement.

ANy help would be appreciated!