[V4RB] How should I use UpdateAll?
Richard Altenburg
valentina at brainchild.nl
Thu Mar 20 14:48:26 CST 2003
On 20-03-2003 14:20, "Ruslan Zasukhin" <sunshine at public.kherson.ua> wrote:
>> I have this cursor that represents one field in thousand of records, that I
>> acquired by doing an SQL SELECT (of course).
>>
>> I set the CurrentPosition in the cursor to 1 (although the reference says it
>> does not matter which one is current), change the value of the only field in
>> the cursor, and do an UpdateAll.
>>
>> After checking, there is not one record changed.
>>
>> So at this point I still loop through thousands of records, moving the
>> CurrentPosition one by one. It is reasonably fast, but I know UpdateAll
>> would do this much more efficient.
>>
>> Anyone can help me?
>
> Hi Richard,
>
> Better to use SQL command -- UPDATE ... WHERE
>
> UpdateAll() was added to Valentina before that SQL command was implemented.
Using the UPDATE in SQL was what I did first, and it was pretty fast.
But I had a problem: I have an ObjectPtr in a table, and it should of course
be filled with a numeric value (the RecID of the record in the one table it
points to).
Using the UPDATE command I could not make it. Whatever I did, the RecID I
put into the ObjectPtr field was interpreted as a string. Usinbg viSQL I did
some tests, and I could not SELECT the records on their numeric value. The
result was 0 records. When I searched on the string value, I got all the
records I wanted to find.
My SQL looked something like this:
"UPDATE AvailableGroup SET ServerRecID="+staticTextID.Text+" WHERE
ServerRecID=0"
Of course I know staticTextID.Text is a string, but concatenated to the SQL
string this should be right, not?
Anyhow, whatever I did, this did not work, so I got to using a loop in which
I fill the value of the type-casted ObjectPtr-field with a numeric form of
the ID in the staticText. That works, but slower.
Can you tell me then how to do the UPDATE in SQL and get a proper numeric
value into the ServerRecID instead of a string value?
More information about the Valentina
mailing list