<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: ActiveRecord create_or_update based on natural-key</title>
	<atom:link href="http://pathfindersoftware.com/2009/01/activerecord-create_or_update-based-on-natural-key/feed/" rel="self" type="application/rss+xml" />
	<link>http://pathfindersoftware.com/2009/01/activerecord-create_or_update-based-on-natural-key/</link>
	<description>The Fastest Way to Launch Successful Software</description>
	<lastBuildDate>Thu, 19 Jan 2012 16:36:03 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Andrew Herron</title>
		<link>http://pathfindersoftware.com/2009/01/activerecord-create_or_update-based-on-natural-key/#comment-9190</link>
		<dc:creator>Andrew Herron</dc:creator>
		<pubDate>Fri, 09 Jan 2009 16:16:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=1351#comment-9190</guid>
		<description>I dug into the code for the plugin and it appears to take advantage of the MySQL syntax for insert.

What other database systems were you looking to use?

A separate version for SQLite could be written using the ON CONFLICT clause:
http://www.sqlite.org/lang_conflict.html

It doesn&#039;t look so easy with Postgres and you might need a trigger for that. While needing a second query, it would at least be run in the DB and not require a new call through the Rails DB layer.

There are ways of creating a single query that would include conditionals to also do this though I&#039;m not sure how complex or taxing it would be on some systems. Here&#039;s some discussion on how to do it with Oracle:
http://www.sqlrecipes.com/sql_questions_answers/insert_update_record_if_already_exists-6/</description>
		<content:encoded><![CDATA[<p>I dug into the code for the plugin and it appears to take advantage of the MySQL syntax for insert.</p>
<p>What other database systems were you looking to use?</p>
<p>A separate version for SQLite could be written using the ON CONFLICT clause:<br />
<a href="http://www.sqlite.org/lang_conflict.html" rel="nofollow">http://www.sqlite.org/lang_conflict.html</a></p>
<p>It doesn&#8217;t look so easy with Postgres and you might need a trigger for that. While needing a second query, it would at least be run in the DB and not require a new call through the Rails DB layer.</p>
<p>There are ways of creating a single query that would include conditionals to also do this though I&#8217;m not sure how complex or taxing it would be on some systems. Here&#8217;s some discussion on how to do it with Oracle:<br />
<a href="http://www.sqlrecipes.com/sql_questions_answers/insert_update_record_if_already_exists-6/" rel="nofollow">http://www.sqlrecipes.com/sql_questions_answers/insert_update_record_if_already_exists-6/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sharad Jain</title>
		<link>http://pathfindersoftware.com/2009/01/activerecord-create_or_update-based-on-natural-key/#comment-9189</link>
		<dc:creator>Sharad Jain</dc:creator>
		<pubDate>Thu, 08 Jan 2009 23:08:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=1351#comment-9189</guid>
		<description>Andrew, Thanks for pointing me to ar-extensions. I was unaware of it. It seems Model.import with :on_duplicate_key_update is what could be used. I wonder if it is database agnostic. Thanks.</description>
		<content:encoded><![CDATA[<p>Andrew, Thanks for pointing me to ar-extensions. I was unaware of it. It seems Model.import with <img src='http://pathfindersoftware.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> n_duplicate_key_update is what could be used. I wonder if it is database agnostic. Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Herron</title>
		<link>http://pathfindersoftware.com/2009/01/activerecord-create_or_update-based-on-natural-key/#comment-9188</link>
		<dc:creator>Andrew Herron</dc:creator>
		<pubDate>Thu, 08 Jan 2009 22:29:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=1351#comment-9188</guid>
		<description>Why not use AR-Extensions?

In my case I&#039;m working with over 20,000 rows for my &#039;import&#039; so running 40k queries (as your method would require) rather than 20k would be too costly.</description>
		<content:encoded><![CDATA[<p>Why not use AR-Extensions?</p>
<p>In my case I&#8217;m working with over 20,000 rows for my &#8216;import&#8217; so running 40k queries (as your method would require) rather than 20k would be too costly.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic (User agent is rejected)
Page Caching using memcached (User agent is rejected)

Served from: pathfindersoftware.com @ 2012-02-10 02:38:18 -->
