|Oracle® Objects for OLE Developer's Guide
11g Release 2 (11.2) for Microsoft Windows
|PDF · Mobi · ePub|
Reads the data from a
RAW field into a
Variant and returns the amount of data read.
The arguments for the method are:
||The name of the
||The number of bytes in the field to skip before copying data.|
||The number of bytes to copy.|
When possible, the
GetChunkByteEx 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
GetChunkByteEx method requests the necessary data from the database as required. As part of this process, data from all fields (except the
RAW field) in the dynaset are retrieved and compared to the cached values for consistency. If any changes have occurred since the fetch of the original partial data, then the
GetChunkByteEx method aborts the operation with an error.
GetChunkByteEx method takes in a
Variant as the first parameter, instead of the first element of the
ByteArray as in the
GetChunkByte method, only the
GetChunkByteEx method can be used within an ASP/IIS environment.
RAW field is less than 65280 bytes in size, it is quicker to retrieve the data using the
Value property than using the
This example demonstrates the use of the
GetChunkByteEx method to retrieve a
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
type_longraw. Copy and paste this code into the definition section of a form. Call this procedure with a valid file name.
Sub GetChunkByteExExample (FName As String) 'Declare various variables Dim bytesread As Integer, ChunkSize As Long , bytearr() as byte Dim I As Integer, FNum As Integer, CurChunk '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 bytesread = OraDynaset.Fields("type_longraw").GetChunkByteEx(CurChunk,_ I * ChunkSize, ChunkSize) 'redim byte array redim bytearr(bytesread - 1) bytearr = CurChunk Put #FNum, , bytearr 'Write chunk to file. I = I + 1 Loop Until bytesread < ChunkSize 'Close the file. Close FNum frmChunk.MousePointer = DEFAULT End Sub
'This example is for use with ASP (Active Server Pages) <%@ LANGUAGE = VBScript %> <%Response.ContentType = "image/JPEG"%> <% Dim OraDatabase, Oradynaset Dim Chunksize, BytesRead, CurChunkEx 'This assumes a pool of database connections have been created in the global.asa Set OraDatabase = OraSession.getDatabaseFromPool(10) 'This assumes a table called "art_gallery" and 'displays JPEG images stored in the table Set OraDynaset = OraDatabase.CreateDynaset("select art from art_gallery " & _ "where artist = 'Picasso'", 0) BytesRead = 0 'Reading in 32K chunks ChunkSize= 32768 Do BytesRead = OraDynaset.Fields("picture").GetChunkByteEx(CurChunkEx, _ i * ChunkSize, ChunkSize) if BytesRead > 0 then Response.BinaryWrite CurChunkEx end if Loop Until BytesRead < ChunkSize 'Cleanup, remove all local references Set OraDynaset = Nothing Set Oradatabase = Nothing %>