Skip Headers
Oracle® Objects for OLE Developer's Guide
11g Release 2 (11.2) for Microsoft Windows

Part Number E17727-03
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

GetChunk Method

Applies To

OraField Object

Description

Returns a string containing the bytes of all or a portion of a LONG or LONG RAW field.

Usage

data_string = orafield.GetChunk(offset, numbytes)
data_string = orafield.DbGetChunk(offset, numbytes)  

Arguments

The arguments for the method are:

Arguments Description
offset The number of bytes of the field to skip before copying data.
numbytes The number of bytes to copy.

Remarks

The GetChunk method typically retrieves the specified bytes from the local cache. If data is not found in the cache, then the GetChunk method requests it from the database. Data from all fields (except the LONG or LONG RAW field) in the dynaset are retrieved and compared to the cached values for consistency. If any changes have occurred since the last fetch, then the GetChunk method stops the operation which causes an error and returns a Null string.

If a LONG or LONG RAW field is less than 65280 bytes, it is quicker to retrieve the data using the Value property than using the GetChunk method. You cannot use the GetChunk method on a LONG or LONG RAW field for which you have created an alias.

See "Migration from LONG RAW to LOB or BFILE".

Examples

This example demonstrates the use of the GetChunk method to retrieve a LONG RAW column of a database and save it as a file. This example expects a valid dynaset named OraDynaset representing a table with a column named longraw. Copy and paste this code into the definition section of a form. Call this procedure with a valid file name.

Sub GetChunkExample (FName As String)
 
'Declare various variables
Dim CurSize As Integer, ChunkSize  As Long
Dim I As Integer, FNum As Integer, CurChunk As String
 
'Set the size of each chunk
ChunkSize = 10240
 
frmChunk.MousePointer = HOURGLASS
 
'Get a free file number
FNum = FreeFile
 
'Open the file
Open FName For Binary As #FNum
 
 I = 0
'Loop through all of the chunks. Oracle does not return the size of columns >
' 64KB. We should loop until the length of our block is less than we asked for.
Do
 CurChunk = OraDynaset.Fields("LONGRAW").GetChunk(I * ChunkSize, ChunkSize)
 CurSize = Len(CurChunk) 'Get the length of the current chunk.
 
 Put #FNum, , CurChunk   'Write chunk to file.
 I = I + 1
Loop Until CurSize < ChunkSize
 
'Close the file.
Close FNum
 
frmChunk.MousePointer = DEFAULT
 
End Sub