[V4RB] How should I use UpdateAll?
Ruslan Zasukhin
sunshine at public.kherson.ua
Thu Mar 20 16:14:13 CST 2003
on 3/20/03 3:48 PM, Richard Altenburg at valentina at brainchild.nl wrote:
>> 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?
Yes, right. This is normal way -- we always build some SQL strings.
> 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?
Why you say that you work with string value ???
You get query as
UPDATE AvailableGroup SET ServerRecID=5
WHERE ServerRecID=0
Where you see strings?
Yes, staticTextID.Text is string, but this is because we build SQL STRING
for query.
In SQL strings are quotes, e.g.
field = '5' // this is really STRING '5'
Query
UPDATE AvailableGroup SET ServerRecID=5
WHERE ServerRecID=0
Must works!
Does it work for you ?
--
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://listserv.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------
More information about the Valentina
mailing list