[V4MD] GotoRecord() Bug?
Ruslan Zasukhin
sunshine at public.kherson.ua
Fri Oct 31 12:26:11 CST 2003
on 10/31/03 11:45, Martin Kloss at martin.kloss at gmx.de wrote:
> 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?
Send me small db and small script that this show.,
Also I wonder, why not to use GROUP BY in your case?
--
Best regards,
Ruslan Zasukhin [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com
To subscribe to the Valentina mail list go to:
http://lists.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------
More information about the Valentina
mailing list