[V4MD] GotoRecord() Bug?

Martin Kloss martin.kloss at gmx.de
Fri Oct 31 10:45:59 CST 2003


Hi,

I have found a buggy behavior when using "Cursor.GotoRecord()"
with a cursor that contains pointer fields.

Example:
2 tables, "data" and "data_types".
"data" has the fields "id, type_ptr" (a ptr to "data_types")
"data_types" has the field "type_name"

SQL to create cursor:
"SELECT RecID, id, type_name FROM data, data_types ORDER BY id ASC"

So I get a list of data_type names from the join.
Now I can step through the records with NextRecord() etc.
Everthing works fine.

BUT, I want to find out how many records there are in a series of
the same data type, so I move the cursor to check when the data type
changes.

   myRecordCount = pCursor.GetRecordCount()
   myCurrentPos = pCursor.GetPosition()
   myCurrentDataType = pCursor.GetField("type_name")
   repeat with i = myCurrentPos to myRecordCount
     -- ok = pCursor.GotoRecord(myCurrentPos+1) -- THIS DOES NOT WORK
     ok = pCursor.NextRecord() -- THIS WORKS
     if ok then
       curType = pCursor.GetField("type_name")
       if curType = myCurrentDataType then
         -- same datatype increment count
         myCount = myCount + 1
       else
         -- different datatype, break
         exit repeat
       end if
     else
       exit repeat
     end if
   end repeat
   -- restore cursor pos
   pCursor.GotoRecord(myCurrentPos)
   return myCount

Now you would expect that

ok = pCursor.GotoRecord(myCurrentPos+1) -- THIS DOES NOT WORK
ok = pCursor.NextRecord() -- THIS WORKS

would return the same result. But with "GotoRecord()" I ALWAYS get
the same data type, it never changes! This happens only to the fields
that are joined, not to the fields in the "data" table.

Seems like a bug to me. Ruslan?

Martin.



More information about the Valentina mailing list