Subject Re: Locate
Author Svein Erling Tysvær
Happy Friday afternoon to you too, Thomas!

Why bother using two steps when it can be done in one? Simply use this
SQL:

UPDATE SomeTable SET Field1=:Param1, Field2=:Param2, Field3=:Param3
WHERE Field1=:Param4 AND Field2=:Param5 AND Field3=:Param6

prepare the statement once and loop through your other table assigning
parameters and executing the statement. Using IBO, you would typically
use an IB_DSQL for the UPDATE statement (and then I would check the
RowsAffected property to find out how many rows where modified).

If both tables are in the same database, then you could possibly use
only one statement combining both tables, or use a stored procedure to
do all the work.

HTH,
Set

--- In firebird-support@yahoogroups.com, Thomas Besand wrote:
> Hello ng,
>
> in the application I'm working on right now, I want to walk through
> a table of adresses and look each one up in another table (based on
> a selection of 3-5 fields) to find duplicate values. Tables can have
> roughly a million records.
> I recall to have read that the Locate method built into Delphi data
> components does not make use of any index that might be available in
> the DB. Can someone confirm this? And if it is so, what would be the
> method of choice to accomplish a Locate function.
> I'm thinking about implementing it all in SQL, like:
> SELECT ID FROM SomeTable WHERE Field1='Value1'
> AND Field2='Value2'
> AND Field3='Value3'
> If this query returns at least one record use the ID to update the
> record in question
> 'UPDATE SomeTable SET Field1='NewValue1', Field2='NewValue2',
> Field3='NewValue3' WHERE ID=' + ifoundID
>
> Would that be a better path to follow, especially concerning
> performance?
>
> Thanks for your input.
>
> And have a nice weekend (here in Berlin, Germany it's just starting:
> Friday afternoon!)
>
> Greets
> Thomas Besand