0
votes

In my Lotus Notes script, i do have this piece of logic as shown below. This is basically for two SELECT statements, followed by Fetch for each of the SELECT statement separately and the SELECT is for the same DB2 table with a variation in WHERE clause. The error i'm getting is for the second FETCH. The error i'm getting is ---> Field count mismatch error:

count = 0
If (srccon.Execute(selectstatement, fldLst1) = 0) Then
    Goto GetNextDoc
End If
count = srccon.Fetch(fldLst1)
If ( count = 0 ) Then
    Goto GetNextDoc
End If

The above cursor select and fetch does not give me any error.

The cursor down which is for the same DB2 table with a slight variation in WHERE clause is causing the error:

count1 = 0
If (srccon.Execute(selectstatement1, fldLst) = 0) Then
     Goto GetNextDoc
End If
count1 = srccon.Fetch(fldLst) ---> The error is pointing to this line 
                                   and the error is 

I would appreciate any help in this regard. I would also thank the gentleman who did excellent solution for my previous problem for current date minus 30 days.

With much thanks

1
What are the values for selectstatement, fldLst1, selectstatement1 and fldLst? - Richard Schwartz
selectstatement is SELECT * from TABLE A WHERE A=B and selectstatement1 is SELECT * from TABLE A WHERE A = C. What i meant to say here is the SELECT statement is simple select from the same table with a small change in WHERE condition. fldLst1 = list of columns from TABLE A and fldLst = list of columns from TABLE A - user3328120
It seems like it's not liking something about fldLst. Have you tried using fldLst1 for both queries? - Richard Schwartz
Although Andre's answer suggests that I'm pointing in the wrong direction... - Richard Schwartz
i tried using fldLst1 for both queries and i do get the same error. Thank you Richard. If you any other tips please do let me know. - user3328120

1 Answers

0
votes

I suspect it's because when you call Execute, you're reusing the same LCFieldList object from a previous call. Execute and Select statements append their list of result fields to the object you pass them, so you must pass them an empty fieldlist -- one you just created. Otherwise you get a combined fieldlist of all the fields in the result sets of multiple calls to Select or Execute. You may find the LotusScript chapter of this Redbook useful.