db2 为什么在第一次提取后出现“Field Count Mismatch(字段计数不匹配)”错误?

sg3maiej  于 2022-11-07  发布在  DB2
关注(0)|答案(2)|浏览(169)

我已经尝试了我能想到的所有方法,但在提取时仍然出现错误
我在每个Select语句的多值字段中循环,并需要将返回值存储在另一个多值字段中。它在第一次循环中有效,但在第二次循环时在Fetch中出错。

If lc_conn.IsConnected Then     
    For a = 0 To UBound(uniquePlans)            
        b = 0
        SelectStatement2 = "Select Count(CSSN) as counter From cbsdta.covgold where " &_
        " CEFFDT<" & todaysDate & " And (CTRMDT=0 Or CTRMDT>=" & todaysDate & ") And " &_
        "CDTASRC='GIAS' AND CABSGP='" & groupNo & "' AND CPRODTA='" & uniquePlans(a) & "'"

        Count2 = lc_conn.Execute(SelectStatement2, fldLstRecord2 )
        if Count2 <> 0 then

            While (LC_Conn.Fetch( fldLstRecord2 ) > 0) '<---- Error here on 2nd loop

                redim Preserve CoveredLives(b)
                Set CoveredLives(b) = fldLstRecord2.Lookup("counter").value
                b = b + 1
            Wend
        End if
    Next
    doc.CoveredLives = CoveredLives
End If

感谢所有想法或建议

mcdcgff0

mcdcgff01#

原来,我需要在循环中使用'Delete fldListRecord2'命令清除fldListRecord2。添加该命令后,一切都正常了。我还必须在循环中变暗LCFieldList,以便每次都重新初始化它。

If lc_conn.IsConnected Then
    ReDim Preserve CoveredLives(UBound(uniquePlans))        
    For a = 0 To UBound(uniquePlans)
        Dim fldLstRecord2 As New LCFieldList            
        If (lc_conn.Execute ("Select Count(CSSN) as counter From cbsdta.covgold where " &_
        " CEFFDT < " & todaysDate & " And (CTRMDT = 0 Or CTRMDT > " & todaysDate & ") And " &_
        "CDTASRC = 'GIAS' AND CABSGP = '" & groupNo & "' AND CPRODTA = '" & Right(uniquePlans(a),7) & "'", fldLstRecord2) <> 0) Then            
        End If          
        Set fld = fldLstRecord2.Lookup ("counter")
        While (lc_conn.Fetch(fldLstRecord2) > 0)                
            CoveredLives(a) = fld.text(0)                
            Delete fldLstRecord2
        Wend            
    Next        
    doc.CoveredLives = CoveredLives     
End If

谢谢你的建议

相关问题