<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-23470706.post1720631552105843519..comments</id><updated>2010-01-28T07:25:55.943-08:00</updated><title type='text'>Comments on Developeando: Firebird 2.1 UPDATE OR INSERT</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.developeando.com/feeds/1720631552105843519/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23470706/1720631552105843519/comments/default'/><link rel='alternate' type='text/html' href='http://www.developeando.com/2008/12/firebird-21-update-or-insert.html'/><author><name>Mario Cornejo</name><uri>http://www.blogger.com/profile/01576953695407749789</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-23470706.post-1214743550423921041</id><published>2008-12-09T11:05:28.353-08:00</published><updated>2008-12-09T11:05:28.353-08:00</updated><title type='text'>@Jobin Yes you can use the MERGE statement in Fire...</title><content type='html'>@Jobin Yes you can use the MERGE statement in Firebird for that, but in this example (of just one row) I think it's easier with the UPDATE OR INSERT statement. I use MERGE when I want to insert or update the data from one table to another.&lt;BR/&gt;&lt;BR/&gt;Using the MERGE statement with this example, the SQL looks like this:&lt;BR/&gt;&lt;I&gt;&lt;BR/&gt;MERGE INTO inventory i&lt;BR/&gt;  USING (SELECT p.product_id FROM products p WHERE p.product_id = :product_id) p&lt;BR/&gt;  ON (p.product_id = i.product_id)&lt;BR/&gt;    WHEN MATCHED THEN&lt;BR/&gt;      UPDATE SET&lt;BR/&gt;       i.stock = :stock&lt;BR/&gt;    WHEN NOT MATCHED THEN&lt;BR/&gt;      INSERT (product_id, stock)&lt;BR/&gt;      VALUES (p.product_id, :stock);&lt;BR/&gt;&lt;/I&gt;&lt;BR/&gt;thanks for the feedback</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23470706/1720631552105843519/comments/default/1214743550423921041'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23470706/1720631552105843519/comments/default/1214743550423921041'/><link rel='alternate' type='text/html' href='http://www.developeando.com/2008/12/firebird-21-update-or-insert.html?showComment=1228849528353#c1214743550423921041' title=''/><author><name>Mario H. Cornejo</name><uri>http://www.blogger.com/profile/01576953695407749789</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='17170706445594284324'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.developeando.com/2008/12/firebird-21-update-or-insert.html' ref='tag:blogger.com,1999:blog-23470706.post-1720631552105843519' source='http://www.blogger.com/feeds/23470706/posts/default/1720631552105843519' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-23470706.post-2499758365501485835</id><published>2008-12-09T08:17:17.506-08:00</published><updated>2008-12-09T08:17:17.506-08:00</updated><title type='text'>i think MERGE statments are the new ANSI SQL speci...</title><content type='html'>i think MERGE statments are the new ANSI SQL specifiation for this same purpose. Is it a deviation from standards?</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23470706/1720631552105843519/comments/default/2499758365501485835'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23470706/1720631552105843519/comments/default/2499758365501485835'/><link rel='alternate' type='text/html' href='http://www.developeando.com/2008/12/firebird-21-update-or-insert.html?showComment=1228839437506#c2499758365501485835' title=''/><author><name>Jobin</name><uri>http://www.blogger.com/profile/08283240643885766971</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.developeando.com/2008/12/firebird-21-update-or-insert.html' ref='tag:blogger.com,1999:blog-23470706.post-1720631552105843519' source='http://www.blogger.com/feeds/23470706/posts/default/1720631552105843519' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-23470706.post-683370607701374521</id><published>2008-12-08T08:13:24.479-08:00</published><updated>2008-12-08T08:13:24.479-08:00</updated><title type='text'>Hi,Your first code could be cleaner. Instead of do...</title><content type='html'>Hi,&lt;BR/&gt;&lt;BR/&gt;Your first code could be cleaner. Instead of doing a SELECT to check the existence of the record, do an UPDATE, and ROWCOUNT is zero, do an INSERT.&lt;BR/&gt;&lt;BR/&gt;Thanks for the article.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23470706/1720631552105843519/comments/default/683370607701374521'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23470706/1720631552105843519/comments/default/683370607701374521'/><link rel='alternate' type='text/html' href='http://www.developeando.com/2008/12/firebird-21-update-or-insert.html?showComment=1228752804479#c683370607701374521' title=''/><author><name>Paulo 242 Junqueira</name><uri>http://www.blogger.com/profile/11933529849195106369</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.developeando.com/2008/12/firebird-21-update-or-insert.html' ref='tag:blogger.com,1999:blog-23470706.post-1720631552105843519' source='http://www.blogger.com/feeds/23470706/posts/default/1720631552105843519' type='text/html'/></entry></feed>