[V4RB] API Equivalent of UPDATE WHERE

Ruslan Zasukhin sunshine at public.kherson.ua
Mon Jan 3 23:30:14 CST 2005


On 1/3/05 10:35 PM, "Frank Schima" <frank-list3 at mindstarprods.com> wrote:

>> * But what is bad in looping ?
>>     if this is local db then no problems in fact,
>>     RB is fast on this.
> 
> I thought it would be slower than SQL.

Frank, all depend on task and environment.

In C++ loops will be NEVER slower of SQL, because
    SQL is parser + the same loops.


>> * API way will require more coding. This is a RULE.
>> 
>>     so the pure API way can be:
>> 
>>     set = fldVarChar.FindNulls()
>> 
>>     Iter = set.MakeNewIterator
>>     recid = Iter.first
>> 
>>     do
>>         tbl.RecID = recid
>>         fldVarChar.value = "some text"
>>         tbl.UpdateRecord()
>> 
>>     while recid = iter.next
> 
> I will try this.

BTW, may be more simple to use

    set = fldVarChar.FindNulls()
    fldVarChar.value = "some text"
    Table.UpdateAllRecords( set )



>> * Also your task CAN be made with UpdateAllRecords() as I see.
>> 
>>     curs = db.SqlSelect(
>>                 "SELECT MyVarcharField WHERE MyVarcharField IS NULL" )
>> 
>>     curs.VarCharField(x).valule = "someText"
>> 
>>     curs.UpdateAllRecords()
> 
> Well i have some records with text that i want to preserve because it's
> different than 'some text'. I only want the NULL ones changed.

Frank!

But only NULL records will be selected in the cursor.
So only they will be updated.


>> * keep in mind that API way cannot do JOINS, GROUP BY and so on.
>>     this is RELATIONAL Model features, mirrored in the SQL.
> 
> So SQL will still be needed then for some tasks then right?

Of course!

SQL is simply a choice if you work with remote computer.
Or if you want realtional way,
Or if you need do GROUP BY.

On the other hand, many tasks can be made with Navigational model,
And even more effective, because you as developer always can write better
code that SQL optimizer.



-- 
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-beta mailing list