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: Inserting LOBs using Dynasets

Schema Description

Dim OraSession As OraSession

Dim OraDatabase As OraDatabase

Dim Part As OraDynaset

Dim PartImage as OraBLOB

Dim ImageChunk() As Byte

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 a Dynaset containing a BLOB and a CLOB column

set part = OraDatabase.CreateDynaset ("select * from part",0)

set PartImage = part.Fields("part_image").Value

'First insert Empty LOB in the part_image column

part.AddNew

part.Fields("part_id").Value = 1234

part.Fields("part_image").Value = Empty

part.Update

'move to the newly added row

Part.MoveLast

' To get a free file number

FNum = FreeFile

'Open the file for reading PartImages

Open "part_picture.gif" For Binary As #FNum

'Re adjust the buffer size to hold entire file data

Redim ImageChunk(LOF(FNum))

'read the entire file and put it into buffer

Get #FNum, , ImageChunk

'call dynaset's Edit method to lock the row

part.Edit

amount_written = OraBlob.Write(ImageChunk)

part.Update

'close the file

Close FNum