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 Write of a LOB

Schema Description

Dim OraSession As OraSession

Dim OraDatabase As OraDatabase

Dim OraDynaset As OraDynaset

Dim PartDesc As OraClob

Dim buffer As String

Dim chunksize As Long

Dim amount_written As Long

'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&)

Set PartDesc = OraDynaset.Fields("part_desc").Value

chunksize = 32000

'Re adjust the buffer size

buffer = String$(chunksize, 32)

FNum = FreeFile

'Open the file.

Open "partdesc.dat" For Binary As #FNum

'set the offset and PollingAmount properties for piece wise

'Write operation

PartDesc.offset = 1

PartDesc.PollingAmount = LOF(FNum)

remainder = LOF(FNum)

'Lock the row for write operation

OraDynaset.Edit

Get #FNum, , buffer

'Do first write operation

amount_written = PartDesc.Write(buffer, chunksize,

ORALOB_FIRST_PIECE)

While PartDesc.Status = ORALOB_NEED_DATA

remainder = remainder - chunksize

If remainder < chunksize Then

piecetype = ORALOB_LAST_PIECE

chunksize = remainder

Else

piecetype = ORALOB_NEXT_PIECE

End If

Get #FNum, , buffer

amount_written = PartDesc.Write(buffer, chunksize, piecetype)

Wend

Close FNum

'call Update method to commit the transaction

OraDynaset.Update