Skip Headers

Oracle® Objects for OLE Developer's Guide
10g Release 1 (10.1)

Part Number B10118-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Master Index
Master Index
Go to Feedback page
Feedback

Multiple Piece Read Operation

This mechanism is used when the size of the buffer available is smaller than the total amount of data to be read. The total amount of data to be read is set by using the PollingAmount (OraLOB/BFILE) property. The Offset (OraLOB/BFILE) property is used only once to set the offset for the first piece read operation. After the first time, it is automatically increased by the size of the previous piece.

The Status (OraLOB/BFILE) property must be checked for success of each piece read operation. If Status property returns ORALOB_NEED_DATA, the Read method must be called again. This must continue until the amount specified by PollingAmount property has been read. At the end of multiple piece operation, the Status property returns ORALOB_NO_DATA.

The following example reads 102k of data in 10k chunks from the part_image column at offset of 1000 to the local file 'image.dat'.

Dim buffer as Variant

Dim buf() As Byte

Set OO4OSession = CreateObject("OracleInProcServer.XOraSession")

Set InvDb = OO4OSession.OpenDatabase("INVDB", "scott/tiger", 0)

Set Part = InvDb.CreateDynaset("select * from part", 0&)

Set PartImage = Part.Fields("part_image").Value

FNum = FreeFile

Open "image.dat" For Binary As #FNum

PartImage.offset = 1000

PartImage.PollingAmount = 102000

amount_read = PartImage.Read(buffer, chunksize)

buf = buffer

Put #FNum, , buf

While PartImage.Status = ORALOB_NEED_DATA

amount_read = PartImage.Read(buffer, chunksize)

buf = buffer

Put #FNum, , buf

Wend

Close FNum

The previous lines of code read the part_image LOB data and writes it to image.dat file . At the end of the multiple piece operation, the Status property returns ORALOB_NO_DATA.