Does Oracle's SecureFile LOB allow me to obtain a filehandle to the underlying resource.

Both PostgreSQL through lo_open and SQL Server with FILESTREAM's OpenSqlFilestream allow you to get a native filehandle to a resource tracked by the database. What's the Oracle alternative to this?

  • With PostgreSQL you get a filehandle by providing a resource id (large object id) that is only valid for the duration of the transaction and the DB provides the filehandle.
  • With SQL Server you get a transactionToken which is only valid for the duration of the transaction which you can provide to the OpenSqlFilestream to get a filehandle.
  • Where will code run? (Client or DB server?) Language? 4 digit DB version? Jan 7 '19 at 18:08
  • Server. C. Assume newest versions of everything. Jan 7 '19 at 18:09

No, to SecureFile's exposing a FileHandle

You can not. There is no filehandle to (internal) LOBs. Oracle separates their large binary implementations into ones that are internal, or external. Internal Lobs are tracked with a "Lob Locator" (Oracle terminology) which is of type OCILobLocator in the OCI. You can perform operations on them with the Oracle Call Interface (OCI). The OCI's operations take a Lob Locator as a handle but are not otherwise useful, and do not have an equivalent for all POSIX operations. For example, there is no fseek.

External LOBs

Oracle Provides an "external LOB" called a "BFILE". The BFILE is associated with a path on disk. Using that path, you can manually open the file with open, but there is no transaction token, and the filehandle is not closed at the end of the transaction. Note "BFILE"s do not support deduplication, compression, or encryption and you'll be left to the underlying filesystem of the disk for those faculties.



I am assuming you are looking for the BLOB class.


Be aware, it looks like it requires a "thick client" (OCI) connection. That is, any client would need to have Oracle Client installed. (Servers should already have it installed)

Oracle File System (OFS)

I was originally thinking of DBFS and OFS. These features allow you to turn a TABLE into a File System. If you are on Linux, you can even mount it.


  • That BLOB class isn't returning a filehandle anywhere that I can see. Jan 7 '19 at 18:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.