Reads the data from the LONG
or LONG
RAW
field into byte array and returns the size of data read.
The arguments for the method are:
Arguments | Description |
---|---|
ByteArray |
The first element of the ByteArray to hold the data. |
offset |
The number of bytes in the field to skip before copying data. |
numbytes |
The number of bytes to copy. |
When possible, the GetChunkByte
method retrieves the specified bytes from the local cache. However, to conserve resources, some of the data might not be stored locally. In these cases, the GetChunkByte
method requests the necessary data from the database as required. As part of this process, data from all fields (except the Long or LONG
RAW
field) in the dynaset are retrieved and compared with the cached values for consistency. If any changes have occurred since the fetch of the original partial data, then the GetChunkByte
method stops the operation and an error occurs. In the case of an abort, the returned string is Null
.
If a LONG
or LONG
RAW
field is less than 65280 bytes in size, it is quicker to retrieve the data using the Value
property than using the GetChunkByte
method. You cannot use the GetChunkByte
method on a LONG
or LONG
RAW
field for which you have created an alias.
This example demonstrates the use of the GetChunkByte
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 GetChunkByteExample (FName As String) 'Declare various variables Dim CurSize As Integer, ChunkSize As Long Dim I As Integer, FNum As Integer, CurChunk() As Byte 'Set the size of each chunk ChunkSize = 10240 'Redim CurChunk Array ReDim CurChunk(ChunkSize) 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 CurSize = OraDynaset.Fields("type_longraw").GetChunkByte(CurChunk(0), I * ChunkSize, ChunkSize) If CurSize > 0 AND CurSize < ChunkSize Then ReDim CurChunk(CurSize) CurSize = OraDynaset.Fields("type_longraw").GetChunkByte(CurChunk(0), I * ChunkSize, CurSize) End If Put #FNum, , CurChunk 'Write chunk to file. I = I + 1 Loop Until CurSize <= 0 'Close the file. Close FNum frmChunk.MousePointer = DEFAULT End Sub
See Also:
"Migration from LONG RAW to LOB or BFILE" for additional information