[odb-users] Storing files in an oracle database

Boris Kolpackov boris at codesynthesis.com
Wed Feb 18 10:19:14 EST 2015

Hi Marcel,

Marcel Nehring <mne at qosmotec.com> writes:

> I want to use Oracle's BFILE column type to store a binary file in the
> database. ODB does not come with a mapping for this DB type and I don't
> want to have the possibly large file floating around in memory anyway.

ODB can be smarter than that. For example, for LOBs we use locators
and pump the data in/out in chunks via a callback mechanism.

> My first idea was to use something like a virtual data member without
> having any representation of it in my persistent class. I want ODB to
> generate an additional column of type BFILE in my table but I don't
> want to have a member representing this column in my class. Instead
> I thought of loading the corresponding file manually in chunks and
> store it locally on disk. 

Skimming through the OCI docs, BFILE appears to be special in that
on INSERT or UPDATE you specify the file name, not its data. Not
sure what SELECT returns...

I wonder if there is a way to cast BFILE to BLOB? If this were
possible then you could map BFILE to BLOB and use the BFILENAME
function for INSERT and UPDATE (the 'to' expression) and cast to
BLOB for SELECT (the 'from' expression). See Section 14.8,
"Database Type Mapping Pragmas".


More information about the odb-users mailing list