引数
このメソッドの引数は、次のとおりです。
引数 | 説明 |
---|---|
ByteArray |
データを格納するVariant 型のバイト配列の名前。
|
offset |
データのコピー前にスキップするフィールド内のバイト数。 |
numbytes |
コピーするバイト数。 |
備考
可能な場合、GetChunkByteEx
メソッドは、ローカル・キャッシュから指定されたバイト数を取り出します。ただし、一部のデータは、リソース節約のために、ローカルに格納されない場合があります。この場合、GetChunkByteEx
メソッドは、必要に応じてデータベースから必要なデータを要求します。この処理の一部として、ダイナセット内のすべてのフィールド(LONG
またはLONG
RAW
型のフィールドを除く)が取り出されて、一貫性検査のためにキャッシュされている値と比較されます。元の部分データのフェッチ後に変更があった場合、GetChunkByteEx
は操作を中止し、エラーを戻します。
GetChunkByteEx
メソッドの最初のパラメータは、バイト配列の最初の要素を指定するGetChunkByte
メソッドとは異なり、Variant
であるため、ASP/IIS環境ではGetChunkByteEx
メソッドのみ使用可能です。
LONG
またはLONG
RAW
型のフィールドが65280バイト未満の場合は、GetChunkByteEx
メソッドを使用せずにValue
プロパティを使用すると、データを速く取り出すことができます。
「LONG RAWからLOBまたはBFILEへの移行」を参照してください。
例
GetChunkByteExメソッドを使用してLONG RAW型の列を取り出す例
この例では、GetChunkByteEx
メソッドを使用してデータベース内のLONG
RAW
型の列を取り出し、ファイルとして保存する方法を示します。この例では、type_longraw
という列を含んだ表を示すOraDynaset
という有効なダイナセットが存在していると想定しています。このコードをコピーして、フォームの定義セクションに貼り付けてください。このプロシージャは、有効なファイル名を使用してコールしてください。
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
Active Server Pages(ASP)でGetChunkByteExメソッドを使用する例
'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 %>