UpdateAllRecords Not Working Properly?
Ken Ray
kray at sonsothunder.com
Thu Apr 22 00:19:02 CDT 2004
I thought that when you get a cursor against multiple records in a table and
then iterate through them changing field values and then use
Cursor_UpdateAllRecords, that every single record in the cursor would get
updated...
What I'm getting is that the change made to what is the "last" record in the
cursor is being set for all records in the cursor. Here's a simple example
(assume tSQL contains the SQL command to get a set of records from the
table):
on mouseUp
put Valentina("Database_SQLSelect",gMainDBRef,tSQL) into tCurs
put Valentina("Cursor_GetRecordCount",tCurs) into tNumRecs
get Valentina("Cursor_FirstRecord",tCurs)
repeat with x = 1 to tNumRecs
if x <> tNumRecs then
get Valentina("Cursor_SetField",tCurs,"Name","Fred"
else
get Valentina("Cursor_SetField",tCurs,"Name","John"
end if
get Valentina("Cursor_NextRecord",tCurs)
end repeat
get Valentina("Cursor_UpdateAllRecords",tCurs)
get Valentina("Cursor_Remove",tCurs)
end mouseUp
When I run this, every one of the records in the cursor has the "Name" field
set to "John", even though it's only supposed to be set for the last record
in the cursor. I have a workaround where I get a cursor for each record,
change it, and then use UpdateRecord and Remove inside the loop, but it's
pretty inefficient.
My question is: Is this the way UpdateAllRecords is supposed to work? Or is
this a legitimate bug?
Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/
More information about the Valentina
mailing list