UpdateAllRecords Not Working Properly?

Ruslan Zasukhin sunshine at public.kherson.ua
Thu Apr 22 08:29:10 CDT 2004


On 4/22/04 8:19 AM, "Ken Ray" <kray at sonsothunder.com> wrote:

> 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...

You not correctly understand it.

You need change only once values of one or few fields.
then
    cursor.UpdateAll()

Will set ALL records of cursor to that values.

This is analog of SQL

    UPDATE T SET f1 = v1, f2 = v2 WHERE ...


 
> 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?

-- 
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