0

我正在研究 Pervasive SQL 2000i SP4 并通过 Btrieve API 访问我的数据。最近我深入研究了GetNextExtended操作并使用了“EG”选项,但总是忽略其中的第一条记录。考虑到第一条记录,我决定切换到“UC”选项,但这导致重复返回相同的记录。我生成的数据缓冲区不包含“条款”。

任何帮助将不胜感激。

'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

这是 MKDE 跟踪日志的摘录,其中使用了“UC”选项,这导致重复返回相同的记录:

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   ..Y@......$@....
       00 c0 72 40 00 00 00 00 - 00 00 00 00 00 00 00 00   .Àr@............
       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    ........Y@.....
       00 24 40 00 00 00 00 00 - c0 72 40 00 00 00 00 00   .$@.....Àr@.....
       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     ........Y@....
       00 00 24 40 00 00       -                           ..$@..          
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     ........Y@....
       00 00 24 40 00 00       -                           ..$@..          
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     ........Y@....
       00 00 24 40 00 00       -                           ..$@..          
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:       ??                      -                           .               

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

只是在跟踪日志上的一个注释,从事务 0008 到 0011,所有数据都与 0007 完全相同,因此为了一些急需的简洁性,这些条目被省略了。在 0011 之后,我手动停止了循环,因为它会无限期地继续返回相同的记录。

4

1 回答 1

1

好的,现在我看到了问题所在。由于您将要返回的记录数设置为 1,因此您只会获得 1 条记录。因为您已将其设置为“UC”,所以它将从当前记录开始并返回一条记录……相同的记录,无论您运行代码多少次。
GetNextExtended 中没有神奇的“返回表中的所有记录”。您需要将“要返回的记录数”设置为适合大约 62K 的记录数。最大值实际上是 64K 减去一些开销。PSQL 文档中实际上有一个公式。此外,“UC”选项只能在第一次调用 GNE 时使用。之后,将其切换到“EG”,以便沿记录前进。

于 2011-01-24T17:25:14.057 回答