Here's my built lcSQL string:

            lcSQL = [update addresses set iactive = 0 where iacctid = ] 
+ ALLTRIM(STR(toRecord.iacctid)) + [ and caddrtype = '] + ;
                    ALLTRIM(toRecord.cAddrType) + [' and iactive = 1]


Question:  rather than just blindly run this, would it be better 
performancewise I wonder if I should do a SELECT first to see if any 
such records exist prior to calling the update sql?  Example (after 
dynamically built):

    select iid from addresses where iacctid = '1234' and caddrtype = 'S' 
and iactive = 1 LIMIT 1

This query would tell me if a data condition exists that requires the 
UPDATE sql.  Otherwise, the UPDATE sql is not needed.

I mean, if no records exist, what's the point (even though my WHERE 
clause clearly states the condition).  I'm trying to hit the database 
the LEAST number of times and thinking that the SELECT with the LIMIT 1 
clause may save me cycles/trips as opposed to just letting the UPDATE 
sql go through the entire table (well, perhaps not the entire table 
since it's indexed on iacctid).

Is this much to do about nothing?  <g>

-- 
Michael J. Babcock, MCP
MB Software Solutions, LLC
http://mbsoftwaresolutions.com
http://fabmate.com
"Work smarter, not harder, with MBSS custom software solutions!"



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/%(messageid)s
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to