2011-01-19 13 views
0

私はPervasive SQL 2000i SP4で作業しており、Btrieve API経由でデータにアクセスしています。 最近、私は 'EG'オプションを使用して操作を行いましたが、最初のレコードは常に無視されました。最初のレコードを考慮に入れて、私は 'UC'オプションに切り替えることにしましたが、同じレコードが繰り返し返されました。生成するデータバッファには「Terms」は含まれていません。Btrieve GetNextExtended 'UC'オプション1回だけレコードを繰り返し返す

ご協力いただければ幸いです。 、

MicroKernel Database Engine [Workstation Edition] for Windows NT/95/98 
trace file 
Created : 24 January 2011 16:04:28 

<In> 0001 Opcode : 0026 Crs ID : 0xffffffff Db Length : 00005 
Keynum : ff Clnt ID : 00 00 00 00 00 00 00 00 00 00 F4 0C 57 52 F4 0C 
Clock : 00009d19 Time : Mon Jan 24 16:04:28 2011 
DBuf: 00 00 00 00 00   -       .....   
KBuf: ??      -       .    

<Out>0001 Status : 0000 Crs ID : 0xffffffff Db Length : 00005 
Keynum : ff Clnt ID : 00 00 00 00 00 00 00 00 00 00 F4 0C 57 52 F4 0C 
Clock : 00009d19 Time : Mon Jan 24 16:04:28 2011 
DBuf: 07 00 5a 00 39   -       ..Z.9   
KBuf: ??      -       .    

--------------------------------------------------------------------- 
<In> 0002 Opcode : 0000 Crs ID : 0xffffffff Db Length : 00008 
Keynum : 00 Clnt ID : 00 00 00 00 00 00 00 00 00 00 F4 0C 57 52 F4 0C 
Clock : 00009d1a Time : Mon Jan 24 16:04:28 2011 
DBuf: 4e 4f 54 53 48 4f 57 4e - 00      NOTSHOWN.  
KBuf: 43 3a 5c 50 61 73 74 65 - 6c 30 39 5c 5f 44 65 6d C:\Pastel09\_Dem 
     6f 5c 61 63 63 72 65 63 - 70 74 2e 64 61 74 00 00 o\accrecpt.dat.. 
     00 00 00 0c bd 06 d4 84 - 6b 3e 3a 47 ac 10 5e 78 ....½.Ô„k>:G¬.^x 
File: "C:\Pastel09\_Demo\accrecpt.dat" 

<Out>0002 Status : 0000 Crs ID : 0x00010000 Db Length : 00008 
Keynum : 00 Clnt ID : 00 00 00 00 00 00 00 00 00 00 F4 0C 57 52 F4 0C 
Clock : 00009d1d Time : Mon Jan 24 16:04:28 2011 
DBuf: 4e 4f 54 53 48 4f 57 4e - 00      NOTSHOWN.  
KBuf: 43 3a 5c 50 61 73 74 65 - 6c 30 39 5c 5f 44 65 6d C:\Pastel09\_Dem 
     6f 5c 61 63 63 72 65 63 - 70 74 2e 64 61 74 00 00 o\accrecpt.dat.. 
     00 00 00 0c 43 4f 4d 50 - 32 5c 50 69 65 74 69 65 ....COMP2\Pietie 

--------------------------------------------------------------------- 
<In> 0003 Opcode : 0015 Crs ID : 0x00010000 Db Length : 00028 
Keynum : fe Clnt ID : 00 00 00 00 00 00 00 00 00 00 F4 0C 57 52 F4 0C 
Clock : 00009d1d Time : Mon Jan 24 16:04:28 2011 
DBuf: 00 00 d3 01 fe ff ff ff - 1e 23 9e 77 30 00 b0 01 ..Ó.þÿÿÿ.#žw0.°. 
     e8 cc 01 66 00 00 00 00 - 88 fe e9 05    èÌ.f.....þé.  
KBuf: 00 00 00 00 00 00 01 00 - 88 fe e9 05 1c 00 00 00 .........þé..... 
     60 fe e9 05 00 00 b0 01 - 22 00 c9 01 00 00 00 00 `þé...°.".É..... 
     a4 03 00 00 b8 fe e9 01 - 68 00 b0 01 ff ff ff ff ¤...¸þé.h.°.ÿÿÿÿ 
     00 00 1a 00 08 00 00 00 - 00 07 db 4a 4d 81 4d 51 ..........ÛJM.MQ 
     00 00 00 00 ff ff ff ff - 00 00 00 00 00 00 00 00 ....ÿÿÿÿ........ 
     00 00 f4 0c 57 52 f4 0c - ff 00 00 00 00 00 00 00 ..ô.WRô.ÿ....... 
     8c 5e 9d 77 9c 17 bb 75 - 9c 03 00 00 00 00 00 00 Œ^.wœ.»uœ....... 
     c4 17 bb 75 72 59 c5 fb - 00 00 00 00 00 00 00 00 Ä.»urYÅû........ 

<Out>0003 Status : 0000 Crs ID : 0x00010000 Db Length : 00013 
Keynum : fe Clnt ID : 00 00 00 00 00 00 00 00 00 00 F4 0C 57 52 F4 0C 
Clock : 00009d1d Time : Mon Jan 24 16:04:28 2011 
DBuf: 09 00 80 03 09 0d 10 08 - 0c 0c 0c 01 0a   ............. 
KBuf: 00 00 00 00 00 00 01 00 - 88 fe e9 05 0d 00 00 00 .........þé..... 
     60 fe e9 05 00 00 b0 01 - 22 00 c9 01 00 00 00 00 `þé...°.".É..... 
     a4 03 00 00 b8 fe e9 01 - 68 00 b0 01 ff ff ff ff ¤...¸þé.h.°.ÿÿÿÿ 
     00 00 1a 00 08 00 00 00 - 00 07 db 4a 4d 81 4d 51 ..........ÛJM.MQ 
     00 00 00 00 ff ff ff ff - 00 00 00 00 00 00 00 00 ....ÿÿÿÿ........ 
     00 00 f4 0c 57 52 f4 0c - ff 00 00 00 00 00 00 00 ..ô.WRô.ÿ....... 
     8c 5e 9d 77 9c 17 bb 75 - 9c 03 00 00 00 00 00 00 Œ^.wœ.»uœ....... 
     c4 17 bb 75 72 59 c5 fb - 00 00 00 00 00 00 00 00 Ä.»urYÅû........ 

--------------------------------------------------------------------- 
<In> 0004 Opcode : 0015 Crs ID : 0x00010000 Db Length : 01936 
Keynum : 00 Clnt ID : 00 00 00 00 00 00 00 00 00 00 F4 0C 57 52 F4 0C 
Clock : 00009d1e Time : Mon Jan 24 16:04:28 2011 
DBuf: 33 00 cb ff ff ff ff ff - ff ff ff ff ff ff ff 00 3.Ëÿÿÿÿÿÿÿÿÿÿÿÿ. 
     00 00 00 00 00 00 00 00 - 00 80 03 09 0d 10 08 0c ................ 
     0c 0c 01 0a 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 
     00 00 00 20 20 20 20 20 - 00 00 00 00 00 00 00 00 ...  ........ 
     00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 
     00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 
     00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 
     00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 
     00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 
     00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 
     00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 
     00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 
     00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 
     00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 
     00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 
     00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 
KBuf:        -           

<Out>0004 Status : 0000 Crs ID : 0x00010000 Db Length : 00352 
Keynum : 00 Clnt ID : 00 00 00 00 00 00 00 00 00 00 F4 0C 57 52 F4 0C 
Clock : 00009d1e Time : Mon Jan 24 16:04:28 2011 
DBuf: 80 03 00 04 09 00 04 00 - 00 00 00 03 03 00 00 00 ................ 
     05 00 08 00 13 01 04 00 - 00 00 00 00 00 00 00 00 ................ 
     0d 00 01 00 03 01 04 00 - 00 00 00 00 00 00 00 00 ................ 
     0d 00 01 00 13 01 04 00 - 00 00 00 00 00 00 01 00 ................ 
     01 00 04 00 13 01 04 00 - 00 00 01 00 00 00 01 00 ................ 
     05 00 08 00 03 01 04 00 - 00 00 00 00 00 00 01 00 ................ 
     05 00 08 00 13 01 04 00 - 00 00 00 00 00 00 02 00 ................ 
     14 00 01 00 13 01 04 00 - 00 00 00 00 00 00 02 00 ................ 
     15 00 07 00 03 01 04 00 - 00 00 00 00 00 00 02 00 ................ 
     14 00 01 00 13 01 04 00 - 00 00 00 00 00 00 03 00 ................ 
     15 00 07 00 03 01 04 00 - 00 00 00 00 00 00 03 00 ................ 
     01 00 04 00 13 01 04 00 - 00 00 01 00 00 00 04 00 ................ 
     05 00 08 00 03 01 04 00 - 00 00 00 00 00 00 04 00 ................ 
     14 00 01 00 13 01 04 00 - 00 00 00 00 00 00 05 00 ................ 
     15 00 07 00 13 01 04 00 - 00 00 00 00 00 00 05 00 ................ 
     01 00 04 00 03 01 04 00 - 00 00 01 00 00 00 05 00 ................ 
KBuf:        -           

--------------------------------------------------------------------- 
<In> 0005 Opcode : 0012 Crs ID : 0x00010000 Db Length : 00896 
Keynum : 00 Clnt ID : 00 00 00 00 00 00 00 00 00 00 F4 0C 57 52 F4 0C 
Clock : 00009d1f Time : Mon Jan 24 16:04:28 2011 
DBuf: 80 03 00 04 09 00 04 00 - 00 00 00 03 03 00 00 00 ................ 
     05 00 08 00 13 01 04 00 - 00 00 00 00 00 00 00 00 ................ 
     0d 00 01 00 03 01 04 00 - 00 00 00 00 00 00 00 00 ................ 
     0d 00 01 00 13 01 04 00 - 00 00 00 00 00 00 01 00 ................ 
     01 00 04 00 13 01 04 00 - 00 00 01 00 00 00 01 00 ................ 
     05 00 08 00 03 01 04 00 - 00 00 00 00 00 00 01 00 ................ 
     05 00 08 00 13 01 04 00 - 00 00 00 00 00 00 02 00 ................ 
     14 00 01 00 13 01 04 00 - 00 00 00 00 00 00 02 00 ................ 
     15 00 07 00 03 01 04 00 - 00 00 00 00 00 00 02 00 ................ 
     14 00 01 00 13 01 04 00 - 00 00 00 00 00 00 03 00 ................ 
     15 00 07 00 03 01 04 00 - 00 00 00 00 00 00 03 00 ................ 
     01 00 04 00 13 01 04 00 - 00 00 01 00 00 00 04 00 ................ 
     05 00 08 00 03 01 04 00 - 00 00 00 00 00 00 04 00 ................ 
     14 00 01 00 13 01 04 00 - 00 00 00 00 00 00 05 00 ................ 
     15 00 07 00 13 01 04 00 - 00 00 00 00 00 00 05 00 ................ 
     01 00 04 00 03 01 04 00 - 00 00 01 00 00 00 05 00 ................ 
KBuf: 00 00 00 00 00 00 00 00 - 00      .........  

<Out>0005 Status : 0000 Crs ID : 0x00010000 Db Length : 00896 
Keynum : 00 Clnt ID : 00 00 00 00 00 00 00 00 00 00 F4 0C 57 52 F4 0C 
Clock : 00009d1f Time : Mon Jan 24 16:04:28 2011 
DBuf: 01 00 00 00 52 43 31 30 - 30 30 30 31 01 05 41 42 ....RC100001..AB 
     43 44 45 44 41 41 41 41 - 41 41 41 67 00 1b 05 d8 CDEDAAAAAAAg...Ø 
     07 00 46 69 72 73 74 20 - 45 6e 74 72 79 20 20 20 ..First Entry 
     20 20 20 20 20 20 20 20 - 20 20 20 20 20 20 20 20     
     20 20 20 20 20 20 20 20 - 20 20 00 00 00 00 00 00    ...... 
     00 00 59 40 00 00 00 00 - 00 00 24 40 00 00 00 00 [email protected][email protected] 
     00 c0 72 40 00 00 00 00 - 00 00 00 00 00 00 00 00 .À[email protected] 
     00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 
     00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 
     00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 
     00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 
     00 00 00 00 00 00 00 00 - 00 00 00 00 41 6c 62 6f ............Albo 
     74 74 20 4c 69 6d 69 74 - 65 64 20 20 20 20 20 20 tt Limited  
     20 20 20 20 20 20 20 20 - 20 20 20 20 20 20 20 20     
     20 20 20 20 31 34 2f 33 - 33 20 4f 66 66 69 63 65  14/33 Office 
     20 43 72 65 73 63 65 6e - 74 20 20 20 20 20 20 20 Crescent  
KBuf: 52 43 31 30 30 30 30 31 - 01      RC100001.  

--------------------------------------------------------------------- 
<In> 0006 Opcode : 0036 Crs ID : 0x00010000 Db Length : 00102 
Keynum : 00 Clnt ID : 00 00 00 00 00 00 00 00 00 00 F4 0C 57 52 F4 0C 
Clock : 0000ad9b Time : Mon Jan 24 16:04:32 2011 
DBuf: 10 00 55 43 00 00 00 00 - 01 00 01 00 5e 00 00 00 ..UC........^... 
     41 41 67 00 1b 05 d8 07 - 00 46 69 72 73 74 20 45 AAg...Ø..First E 
     6e 74 72 79 20 20 20 20 - 20 20 20 20 20 20 20 20 ntry    
     20 20 20 20 20 20 20 20 - 20 20 20 20 20 20 20 20     
     20 00 00 00 00 00 00 00 - 00 59 40 00 00 00 00 00 [email protected] 
     00 24 40 00 00 00 00 00 - c0 72 40 00 00 00 00 00 [email protected]....À[email protected] 
     00 00 00 00 00 00  -       ......   
KBuf: 20 20 20 20 20 20 20 20 - 20           

<Out>0006 Status : 0000 Crs ID : 0x00010000 Db Length : 00102 
Keynum : 00 Clnt ID : 00 00 00 00 00 00 00 00 00 00 F4 0C 57 52 F4 0C 
Clock : 0000ad9c Time : Mon Jan 24 16:04:32 2011 
DBuf: 01 00 5e 00 00 0b 00 00 - 01 00 00 00 52 43 31 30 ..^.........RC10 
     30 30 30 31 01 05 41 42 - 43 44 45 44 41 41 41 41 0001..ABCDEDAAAA 
     41 41 41 67 00 1b 05 d8 - 07 00 46 69 72 73 74 20 AAAg...Ø..First 
     45 6e 74 72 79 20 20 20 - 20 20 20 20 20 20 20 20 Entry   
     20 20 20 20 20 20 20 20 - 20 20 20 20 20 20 20 20     
     20 20 00 00 00 00 00 00 - 00 00 59 40 00 00 00 00  [email protected] 
     00 00 24 40 00 00  -       [email protected]   
KBuf: 52 43 31 30 30 30 30 31 - 01      RC100001.  

--------------------------------------------------------------------- 
<In> 0007 Opcode : 0036 Crs ID : 0x00010000 Db Length : 00102 
Keynum : 00 Clnt ID : 00 00 00 00 00 00 00 00 00 00 F4 0C 57 52 F4 0C 
Clock : 0000b345 Time : Mon Jan 24 16:04:34 2011 
DBuf: 10 00 55 43 00 00 00 00 - 01 00 01 00 5e 00 00 00 ..UC........^... 
     30 30 30 31 01 05 41 42 - 43 44 45 44 41 41 41 41 0001..ABCDEDAAAA 
     41 41 41 67 00 1b 05 d8 - 07 00 46 69 72 73 74 20 AAAg...Ø..First 
     45 6e 74 72 79 20 20 20 - 20 20 20 20 20 20 20 20 Entry   
     20 20 20 20 20 20 20 20 - 20 20 20 20 20 20 20 20     
     20 20 00 00 00 00 00 00 - 00 00 59 40 00 00 00 00  [email protected] 
     00 00 24 40 00 00  -       [email protected]   
KBuf: 20 20 20 20 20 20 20 20 - 20           

<Out>0007 Status : 0000 Crs ID : 0x00010000 Db Length : 00102 
Keynum : 00 Clnt ID : 00 00 00 00 00 00 00 00 00 00 F4 0C 57 52 F4 0C 
Clock : 0000b345 Time : Mon Jan 24 16:04:34 2011 
DBuf: 01 00 5e 00 00 0b 00 00 - 01 00 00 00 52 43 31 30 ..^.........RC10 
     30 30 30 31 01 05 41 42 - 43 44 45 44 41 41 41 41 0001..ABCDEDAAAA 
     41 41 41 67 00 1b 05 d8 - 07 00 46 69 72 73 74 20 AAAg...Ø..First 
     45 6e 74 72 79 20 20 20 - 20 20 20 20 20 20 20 20 Entry   
     20 20 20 20 20 20 20 20 - 20 20 20 20 20 20 20 20     
     20 20 00 00 00 00 00 00 - 00 00 59 40 00 00 00 00  [email protected] 
     00 00 24 40 00 00  -       [email protected]   
KBuf: 52 43 31 30 30 30 30 31 - 01      RC100001.  

--------------------------------------------------------------------- 
<In> 0012 Opcode : 0001 Crs ID : 0x00010000 Db Length : 00000 
Keynum : 00 Clnt ID : 00 00 00 00 00 00 00 00 00 00 F4 0C 57 52 F4 0C 
Clock : 0000d735 Time : Mon Jan 24 16:04:43 2011 
DBuf:  ??      -       .    
KBuf:  ??      -       .    

<Out>0012 Status : 0000 Crs ID : 0x00000000 Db Length : 00000 
Keynum : 00 Clnt ID : 00 00 00 00 00 00 00 00 00 00 F4 0C 57 52 F4 0C 
Clock : 0000d737 Time : Mon Jan 24 16:04:43 2011 
DBuf:  ??      -       .    
KBuf:  ??      -       .    

--------------------------------------------------------------------- 

ただ、ノートトレースログに:ここで

'Form1 - just a form with one button on it 

Option Explicit 

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _ 
    (Destination As Any, Source As Any, ByVal Length As Long) 


Private Sub Command_Click() 
    GetAllRecords 
End Sub 


Private Sub GetAllRecords() 
    Dim boolContinueLoop As Boolean 
    Dim objBtrvAPI As clsBtrvAPI 

    Set objBtrvAPI = New clsBtrvAPI 
    objBtrvAPI.OpenConnection "C:\Pastel09\_Demo\accrecpt.dat" 

    objBtrvAPI.GetFirst 

    boolContinueLoop = True 

    Do 
     objBtrvAPI.Record = GenerateGetNextExtendedDataBuffer() 
     objBtrvAPI.GetNextExtended 

     If (Not objBtrvAPI.EOF) Then 
      'Read record - not necessary for this test 
     End If 

     boolContinueLoop = (Not objBtrvAPI.EOF) 
    Loop Until Not boolContinueLoop 

    objBtrvAPI.CloseConnection 
    Set objBtrvAPI = Nothing 
End Sub 


Private Function GenerateGetNextExtendedDataBuffer() As Byte() 
    Dim intRecordImageLength As Integer 
    Dim bytDataBuffer() As Byte 
    Dim intDataBufferElementCount As Integer 
    Dim intNoOfLeadingBytesReturnedByExtendedOp As Integer 

    intRecordImageLength = 94 

    ReDim bytDataBuffer(0) 

    AddIntToByteArray bytDataBuffer, intDataBufferElementCount, 0      'Total data buffer size - placeholder, value will be assigned later 
    AddStringToByteArray bytDataBuffer, intDataBufferElementCount, "UC"     'Begin with the current record 
    AddIntToByteArray bytDataBuffer, intDataBufferElementCount, 0      'Max Reject Count 
    AddIntToByteArray bytDataBuffer, intDataBufferElementCount, 0      'Number Of Terms 

    AddIntToByteArray bytDataBuffer, intDataBufferElementCount, 1      'Number of records to retrieve 
    AddIntToByteArray bytDataBuffer, intDataBufferElementCount, 1      'Number of fields to extract 
    AddIntToByteArray bytDataBuffer, intDataBufferElementCount, intRecordImageLength 'Field length - select the entire record in one field 
    AddIntToByteArray bytDataBuffer, intDataBufferElementCount, 0      'Field offset/position 

    'Eight bytes are returned on the GetNextExtended call 
    '2 bytes - number of records returned - at present only one record is returned at one time 
    '2 bytes - length of the record image 
    '4 bytes - a pointer to the record 
    intNoOfLeadingBytesReturnedByExtendedOp = 8 

    SetLeadingBytesToIndicateSize bytDataBuffer, intDataBufferElementCount 

    If (intDataBufferElementCount < intRecordImageLength + intNoOfLeadingBytesReturnedByExtendedOp) Then 
     MakeSize bytDataBuffer, intDataBufferElementCount, intRecordImageLength + intNoOfLeadingBytesReturnedByExtendedOp 
    End If 

    GenerateGetNextExtendedDataBuffer = bytDataBuffer 
End Function 


Public Sub AddIntToByteArray(ByRef pbytDataBuffer() As Byte, _ 
          ByRef pintElementCount As Integer, _ 
          ByVal pintValue As Integer) 
    Dim i As Integer 
    Dim byteValue() As Byte 

    byteValue = ConvertIntToByteArray(pintValue) 

    pintElementCount = pintElementCount + 2 
    ReDim Preserve pbytDataBuffer(pintElementCount - 1) 

    For i = 1 To 0 Step -1 
     pbytDataBuffer(pintElementCount - 1 - i) = byteValue(1 - i) 
    Next i 
End Sub 


Public Sub AddStringToByteArray(ByRef pbytDataBuffer() As Byte, _ 
           ByRef pintElementCount As Integer, _ 
           ByVal pstrValue As String) 
    Dim i As Integer 
    Dim strValueToConvert As String 
    Dim byteValue() As Byte 

    pintElementCount = pintElementCount + Len(pstrValue) 
    ReDim Preserve pbytDataBuffer(pintElementCount - 1) 

    strValueToConvert = StrReverse(pstrValue) 

    For i = Len(pstrValue) To 1 Step -1 
     pbytDataBuffer(pintElementCount - i) = Asc(Mid$(strValueToConvert, i, 1)) 
    Next i 
End Sub 


Private Sub MakeSize(ByRef pbytDataBuffer() As Byte, _ 
        ByRef pintElementCount As Integer, _ 
        ByVal pintSize As Integer) 
    pintElementCount = pintSize 
    ReDim Preserve pbytDataBuffer(pintElementCount - 1) 
End Sub 


Private Sub SetLeadingBytesToIndicateSize(ByRef pbytDataBuffer() As Byte, _ 
              ByRef pintElementCount As Integer) 
    Dim i As Integer 
    Dim byteSize() As Byte 

    byteSize = ConvertIntToByteArray(pintElementCount) 

    For i = 0 To UBound(byteSize) 
     pbytDataBuffer(i) = byteSize(i) 
    Next i 
End Sub 


Private Function ConvertIntToByteArray(ByVal pintValue As Integer) As Byte() 
    Dim byteArray(0 To 1) As Byte 

    CopyMemory byteArray(0), ByVal VarPtr(pintValue), Len(pintValue) 
    ConvertIntToByteArray = byteArray 
End Function 


'clsBtrvAPI 

Option Explicit 

Private Const KEY_BUFFER_LEN = 255 

'Btrieve operations 
Private Const B_OPEN = 0 
Private Const B_CLOSE = 1 
Private Const B_GETFIRST = 12 
Private Const B_STAT = 15 
Private Const B_GETNEXTEXTENDED = 36 

Private Declare Function BTRCALL Lib "wbtrv32.dll" (ByVal OpCode As Integer, PositionBlock As Any, DataBuffer As Any, _ 
                DataLength As Long, KeyBuffer As Any, ByVal KeyLength As Integer, _ 
                ByVal KeyNumber As Integer) As Integer 

Private Type TypePositionBlock 
    PosBlk(128) As Byte 
End Type 

Private Type TypeOwner 
    Owner As String * 8 
End Type 

Private Type TypeKeySpec 
    KeyPos As Integer 
    KeyLen As Integer 
    KeyFlags As Integer 
    KeyTot As String * 4 
    KeyType As String * 1 
    Reserved As String * 5 
End Type 

Private Type TypeStatFileSpecs 
    RecLen As Integer 
    PageSize As Integer 
    IndexTot As Integer 
    RecTot As String * 4 
    FileFlags As Integer 
    Reserved As String * 2 
    UnusedPages As Integer 
    KeyBuf(0 To 119) As TypeKeySpec 
End Type 

Private m_strDataFilePath As String 
Private m_byteFilePosBlk As TypePositionBlock 
Private m_boolFileOpen As Boolean 
Private m_boolEOF As Boolean 
Private m_byteRecordBuffer() As Byte 

Private m_intKeyNum As Integer 


Private Sub Class_Initialize() 
    m_strDataFilePath = "" 
    m_boolFileOpen = False 
    m_boolEOF = True 
    m_intKeyNum = 0 
End Sub 


Private Function GetRecordLen() As Integer 
    Dim typeStat As TypeStatFileSpecs 
    Dim strKeyBuffer As String 
    Dim lngDataBufferLen As Long 
    Dim intKeyBufferLen As Integer 
    Dim intStatus As Integer 

    lngDataBufferLen = Len(typeStat) 
    strKeyBuffer = Space$(KEY_BUFFER_LEN) 
    intKeyBufferLen = KEY_BUFFER_LEN 

    intStatus = BTRCALL(B_STAT, m_byteFilePosBlk, typeStat, lngDataBufferLen, _ 
         ByVal strKeyBuffer, KEY_BUFFER_LEN, 0) 

    If (intStatus = 0) Then 
     'Successfull 
     GetRecordLen = typeStat.RecLen 
    End If 
End Function 


Public Sub CloseConnection() 
    Dim intStatus As Integer 

    intStatus = BTRCALL(B_CLOSE, m_byteFilePosBlk, "", 0, 0, 0, 0) 

    If (intStatus = 0) Then 
     m_boolFileOpen = False 
    End If 
End Sub 


Public Sub GetFirst(Optional ByVal pintKey As Integer = 0) 
    Dim lngDataBufferLen As Long 
    Dim strKeyBuffer As String 
    Dim intKeyBufferLen As Integer 
    Dim intStatus As Integer 

    If (m_boolFileOpen) Then 
     lngDataBufferLen = UBound(m_byteRecordBuffer) 
     strKeyBuffer = Space$(KEY_BUFFER_LEN) 
     intKeyBufferLen = KEY_BUFFER_LEN 

     intStatus = BTRCALL(B_GETFIRST, m_byteFilePosBlk, m_byteRecordBuffer(1), lngDataBufferLen, _ 
          ByVal strKeyBuffer, intKeyBufferLen, pintKey) 

     If (intStatus = 0) Then 
      m_intKeyNum = pintKey 
      m_boolEOF = False 
     End If 
    End If 
End Sub 


Public Sub GetNextExtended() 
    Dim lngDataBufferLen As Long 
    Dim strKeyBuffer As String 
    Dim intStatus As Integer 

    If (m_boolFileOpen) Then 
     lngDataBufferLen = UBound(m_byteRecordBuffer) + 1 
     strKeyBuffer = Space$(KEY_BUFFER_LEN) 

     intStatus = BTRCALL(B_GETNEXTEXTENDED, m_byteFilePosBlk, m_byteRecordBuffer(0), lngDataBufferLen, _ 
          ByVal strKeyBuffer, Len(strKeyBuffer), m_intKeyNum) 

     If (intStatus = 9 Or intStatus = 64) Then 
      m_boolEOF = True 
     Else 
      If (intStatus = 0) Then 
       m_boolEOF = False 
      Else 
       Debug.Assert False 
      End If 
     End If 
    End If 
End Sub 


Public Sub OpenConnection(Optional ByVal pstrDataFilePath As String) 
    Dim typeDataBuffer As TypeOwner 
    Dim strKeyBuffer As String 
    Dim lngDataBufferLen As Long 
    Dim intStatus As Integer 

    typeDataBuffer.Owner = "" 
    m_strDataFilePath = pstrDataFilePath 

    lngDataBufferLen = Len(typeDataBuffer) 
    strKeyBuffer = Chr(34) & m_strDataFilePath & Chr(34) 

    intStatus = BTRCALL(B_OPEN, _ 
         m_byteFilePosBlk, _ 
         typeDataBuffer, _ 
         lngDataBufferLen, _ 
         ByVal strKeyBuffer, _ 
         KEY_BUFFER_LEN, _ 
         0) 

    If (intStatus = 0) Then 
     m_boolFileOpen = True 
     ReDim m_byteRecordBuffer(1 To GetRecordLen) 
    End If 
End Sub 


Public Property Get DataFilePath() As String 
    DataFilePath = m_strDataFilePath 
End Property 

Public Property Let DataFilePath(ByVal pstrValue As String) 
    m_strDataFilePath = pstrValue 
End Property 


Public Property Get EOF() As Boolean 
    EOF = m_boolEOF 
End Property 


Public Property Get Record() As Byte() 
    Record = m_byteRecordBuffer 
End Property 

Public Property Let Record(ByRef pbytValue() As Byte) 
    m_byteRecordBuffer = pbytValue 
End Property 

は、同じレコード内 結果が繰り返し返される「UC」オプションが使用されているMKDEトレースログの抜粋ですトランザクション0008から0011へのすべてのデータは有効に 3と同じであるので、これらのエントリは必要な簡潔さのために除外されました。 0011の後、ループを手動で停止したのは、同じレコードを無期限に返すことだけだったからです。

+0

UCオプションを指定する場合は、現在のレコードを含むフィルタに一致するすべてのレコードを取得する必要があります。 MKDEトレースを有効にして、GetNextExtended呼び出しが送信されていると思われる方法で送信されていることを確認することができます。 GetNextExtendedバッファを作成するコードを投稿することもできます。 – mirtheil

+0

ありがとうございます。私は私の質問にトレースログの一部を含めました。私が拾ったのは、前述のように 'EG'オプションを使用すると、トレースログはGetNextExtended(36)操作の4つのエントリで、成功したステータス(0)を返します。どういうわけか私のアプリでこれらの操作の1つが欠落しています。私は周りを詮索し続けます。 – jakdep

+0

MKDEトレースのデータバッファサイズを128以上に増やすことはできますか?これにより、リターンバッファ全体を見ることができます。 また、GetNextExtendedに入るバッファを読み込むために使用しているコードを投稿できますか? – mirtheil

答えて

1

これで問題が発生しました。返されるレコードの数が1に設定されているため、1レコードしか取得できません。 "UC"に設定されているので、現在のレコードから開始し、1つのレコードを返します。コードを何回実行しても、同じレコードです。
GetNextExtendedには「テーブルのすべてのレコードを返す」という魔法はありません。 「返すレコード数」を約62Kに収まるレコード数に設定する必要があります。最大値は実際には64Kから少しオーバーヘッドです。実際には、PSQLのドキュメントに数式があります。また、 "UC"オプションは、GNEが初めて呼び出されたときにのみ使用してください。その後、それを「EG」に切り替えてレコードを進めます。ステータス9(ファイルの終わり)が返されるまで、GNEコールを続行します。

+0

ありがとう!私はそれを試してみましょう。 – jakdep

+0

最初のコールに「UC」を使用し、後続のコールに「EG」を使用するとそのトリックが行われました。私は呼び出しごとに複数のレコードを返すように調べる必要があります。呼び出しごとに複数のレコードを返すと、パフォーマンスが向上するでしょうか? – jakdep

+0

私はいくつかのテストを行い、約250,000レコードのテーブルの呼び出しごとに最大レコード数を返す方がはるかに高速であることが分かりました。実際にはほぼ100倍速くなります。 – jakdep

関連する問題