Oracle Objects for OLE
Release 9.2

Part Number A95895-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents

Master Index

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


 
Oracle
Copyright © 1994, 2002 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents

Master Index

Feedback