Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I select part of a BLOB field in Oracle?

Tags:

oracle

I have a table in Oracle that stores files as byte arrays in a BLOB field. I want my client to be able to download the stored file in small chunks (as opposed to downloading the whole thing all at once) so I can display a progress bar.

How can I write an Oracle query that retrieves only part of the contents of a BLOB field? I imagine it would be something like this:

SELECT PARTOF(BLOBFIELD, 1000, 2000) AS CHUNK FROM tbl WHERE ID = 1

if I wanted to get 1000 bytes from BLOBFIELD starting at byte 2000.

As a secondary question, are there any performance issues with this? If Oracle has to load the entire BLOB field into memory in order to return part of it, then this wouldn't be a very good idea.

like image 695
MusiGenesis Avatar asked Dec 05 '09 14:12

MusiGenesis


1 Answers

Can you use DBMS_LOB.READ (lob_loc, amount, offset, buffer)?

like image 158
Tony Andrews Avatar answered Oct 04 '22 01:10

Tony Andrews