Oracle® Objects for OLE Developer's Guide 10g Release 1 (10.1) Part Number B10118-01 |
|
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