Yes. if exists(statement) something else something else
The question I have to look up is if the whole operation is one 'unit' or does it have to have transaction control. Is there a 'gap' between the exists() check and the actual sql operation? On Fri, Jan 28, 2011 at 9:15 AM, Che Vilnonis <ch...@asitv.com> wrote: > > Could this be combined with an "ELSE" statement in SQL? That is, insert if > new, update if existing? Thanks, Che > > -----Original Message----- > This is what I'm using at the moment but I'm going to read what you have as > well. I want fast and safe. > > <cfquery datasource="#variables.dsn#"> > if not exists( > Select keywordid > from keywords > where keyword = <cfqueryparam value="#local.keyword#" > cfsqltype="cf_sql_varchar">) > Insert into keywords(keyword) > values(<cfqueryparam value="#local.keyword#" > cfsqltype="cf_sql_varchar">) > </cfquery> > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:341631 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm