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

Example: Multiple piece-wise Read of a LOB

Schema Description

Dim OraSession As OraSession

Dim OraDatabase As OraDatabase

Dim OraDynaset As OraDynaset

Dim PartImage As OraBlob

Dim chunksize As Long

Dim AmountRead As Long

Dim buffer As Variant

Dim buf As String

'Create the OraSession Object.

Set OraSession = CreateObject("OracleInProcServer.XOraSession")

'Create the OraDatabase Object by opening a connection to Oracle.

Set OraDatabase = OraSession.OpenDatabase("ExampleDb",

"scott/tiger", 0&)

'Create the OraDynaset Object.

Set OraDynaset = OraDatabase.CreateDynaset("select * from part", 0&)

'Get OraBlob from OraDynaset

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

'Set Offset and PollingAmount property for piecewise Read operation

PartImage.offset = 1

PartImage.PollingAmount = PartImage.Size

chunksize = 50000

'Get a free file number

FNum = FreeFile

'Open the file

Open "image.dat" For Binary As #FNum

'Do the first read on PartImage, buffer must be a variant

AmountRead = PartImage.Read(buffer, chunksize)

'put will not allow Variant type

buf = buffer

Put #FNum, , buf

' Check for the Status property for polling read operation

While PartImage.Status = ORALOB_NEED_DATA

AmountRead = PartImage.Read(buffer, chunksize)

buf = buffer

Put #FNum, , buf

Wend

Close FNum