I think it may depend on how you make the call. You may do it in one SP and
that'll be one request to the DB and a small one at that. It may work in a
single cfquery as well.

If you don't fancy checking the DB, just attempt to delete the record and
insert it regardless.

Ade

-----Original Message-----
From: Howie Hamlin [mailto:[EMAIL PROTECTED]
Sent: 02 February 2005 21:51
To: CF-Talk
Subject: SQL Q


I have an application where I want to update an exising record or create it
if it doesn't exist (this is for keeping daily stats).  The table is indexed
and does not allow dupes.  I came up with something like this:

<cftransaction>
<cftry>
   insert record
<cfcatch type="any">
   update record
</cfcatch>
</cftry>
</cftransaction>

Basically, if the insert fails then I assume that there is a key violation
and I update the existing record.  Does anyone see a problem with this?  My
thought was that if you do a select first to see if the record exists and
then either insert a new record or update the exising record then that would
still take two trips to the SQL server.

Thanks,

Howie
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.8.2 - Release Date: 28/01/2005


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:192830
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to