<?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: MERGE!</title>
	<atom:link href="http://technology.amis.nl/2005/01/04/merge/feed/" rel="self" type="application/rss+xml" />
	<link>http://technology.amis.nl/2005/01/04/merge/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=merge</link>
	<description></description>
	<lastBuildDate>Fri, 12 Apr 2013 10:04:09 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
	<item>
		<title>By: Lucas Jellema</title>
		<link>http://technology.amis.nl/2005/01/04/merge/#comment-1331</link>
		<dc:creator>Lucas Jellema</dc:creator>
		<pubDate>Sat, 10 Dec 2005 07:26:22 +0000</pubDate>
		<guid isPermaLink="false">/?p=315#comment-1331</guid>
		<description><![CDATA[In Oracle 10gR2 you solve this with the DML Error Log clause, see post &lt;a href=&quot;http://technology.amis.nl/blog/?p=801&quot; rel=&quot;nofollow&quot;&gt;10gR2 New Feature: DML Error Logging &lt;/a&gt;.

Pre 10gR2 you are sort of stuck: the MERGE statement is an Atomic operation: it either completes successfully and in its entirety or it fails - again in its entirety. There is no easy way to programmatically and automatically deal with such recordlevel exceptions in statements.

In PL/SQL, you can make use of Bulk DML operations that are actually bundles up packages of individual statements. Those statements can be processed even if one of them fails, using the EXCEPTIONS INTO clause. However, this requires a procedural approach, which is of course what you wanted to avoid in the first place.

I can also think of a simple way to find the offending record in the MERGE statement: create before record and after record insert and update triggers on the table that you are merging into. In the before record trigger, store the ID of the record in a package variable, in the after record trigger you can remove it again (not really necessary by the way). When the statement fails, you will find the identification of the offending record in the package variable. This may help you deal with the problem, by for example running the MERGE statement again, this time excluding the offending record.

You could try to find the offending record]]></description>
		<content:encoded><![CDATA[<p>In Oracle 10gR2 you solve this with the DML Error Log clause, see post <a href="http://technology.amis.nl/blog/?p=801" rel="nofollow">10gR2 New Feature: DML Error Logging </a>.</p>
<p>Pre 10gR2 you are sort of stuck: the MERGE statement is an Atomic operation: it either completes successfully and in its entirety or it fails &#8211; again in its entirety. There is no easy way to programmatically and automatically deal with such recordlevel exceptions in statements.</p>
<p>In PL/SQL, you can make use of Bulk DML operations that are actually bundles up packages of individual statements. Those statements can be processed even if one of them fails, using the EXCEPTIONS INTO clause. However, this requires a procedural approach, which is of course what you wanted to avoid in the first place.</p>
<p>I can also think of a simple way to find the offending record in the MERGE statement: create before record and after record insert and update triggers on the table that you are merging into. In the before record trigger, store the ID of the record in a package variable, in the after record trigger you can remove it again (not really necessary by the way). When the statement fails, you will find the identification of the offending record in the package variable. This may help you deal with the problem, by for example running the MERGE statement again, this time excluding the offending record.</p>
<p>You could try to find the offending record</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arindam Mukherjee</title>
		<link>http://technology.amis.nl/2005/01/04/merge/#comment-1330</link>
		<dc:creator>Arindam Mukherjee</dc:creator>
		<pubDate>Fri, 09 Dec 2005 23:29:28 +0000</pubDate>
		<guid isPermaLink="false">/?p=315#comment-1330</guid>
		<description><![CDATA[I need one solution.

Suppose 100 rows are being processed in Merge. Now 55th row raises an exception. Now I need to commit the previous 54 rows before leaving the block containing the MERGE statement. So I have written an EXCEPTION block but COMMIT is not Working. In addition to, I have also written &quot;PRAGMA AUTONOMOUS_TRANSACTION;&quot; but this is an exercise in futility.

EXCEPTION
 WHEN OTHERS THEN
  commit;
  v_ErrCode := SQLCODE;
  v_ErrMsg  := SQLERRM;
  DBMS_OUTPUT.PUT_LINE(&#039;Code : &#039;&#124;&#124;SQLCODE&#124;&#124;&#039; And Error Msg --&gt;&gt; &#039;&#124;&#124;v_ErrMsg);

If you have time, please help me get the right way to meet the requirement.]]></description>
		<content:encoded><![CDATA[<p>I need one solution.</p>
<p>Suppose 100 rows are being processed in Merge. Now 55th row raises an exception. Now I need to commit the previous 54 rows before leaving the block containing the MERGE statement. So I have written an EXCEPTION block but COMMIT is not Working. In addition to, I have also written &#8220;PRAGMA AUTONOMOUS_TRANSACTION;&#8221; but this is an exercise in futility.</p>
<p>EXCEPTION<br />
 WHEN OTHERS THEN<br />
  commit;<br />
  v_ErrCode := SQLCODE;<br />
  v_ErrMsg  := SQLERRM;<br />
  DBMS_OUTPUT.PUT_LINE(&#8216;Code : &#8216;||SQLCODE||&#8217; And Error Msg &#8211;&gt;&gt; &#8216;||v_ErrMsg);</p>
<p>If you have time, please help me get the right way to meet the requirement.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hank</title>
		<link>http://technology.amis.nl/2005/01/04/merge/#comment-1329</link>
		<dc:creator>Hank</dc:creator>
		<pubDate>Thu, 15 Sep 2005 21:02:51 +0000</pubDate>
		<guid isPermaLink="false">/?p=315#comment-1329</guid>
		<description><![CDATA[Hi,
Merge have four cases:
1. inbound merge: means upsert local DB (where you are) with remote one via DB link.
2. outbound merge: upsert remote DB with local DB.
3. local merge: target and source are in local DB.
4. remote merge: target and source are in remote DB.

Have no idea if all works with MERG command, please lend you advise on the four MERGEs.

Hank]]></description>
		<content:encoded><![CDATA[<p>Hi,<br />
Merge have four cases:<br />
1. inbound merge: means upsert local DB (where you are) with remote one via DB link.<br />
2. outbound merge: upsert remote DB with local DB.<br />
3. local merge: target and source are in local DB.<br />
4. remote merge: target and source are in remote DB.</p>
<p>Have no idea if all works with MERG command, please lend you advise on the four MERGEs.</p>
<p>Hank</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Jacobsen</title>
		<link>http://technology.amis.nl/2005/01/04/merge/#comment-1328</link>
		<dc:creator>Mike Jacobsen</dc:creator>
		<pubDate>Wed, 13 Jul 2005 13:55:44 +0000</pubDate>
		<guid isPermaLink="false">/?p=315#comment-1328</guid>
		<description><![CDATA[Just tested this in 10g and the bug is still there.]]></description>
		<content:encoded><![CDATA[<p>Just tested this in 10g and the bug is still there.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Derek Lee</title>
		<link>http://technology.amis.nl/2005/01/04/merge/#comment-1327</link>
		<dc:creator>Derek Lee</dc:creator>
		<pubDate>Fri, 03 Jun 2005 09:23:27 +0000</pubDate>
		<guid isPermaLink="false">/?p=315#comment-1327</guid>
		<description><![CDATA[Hi,
I read your document and confirm that my problem (sequence number continues increaing even if no really insert in merge statement)
is an Oracle bug. Thank you for your good article.]]></description>
		<content:encoded><![CDATA[<p>Hi,<br />
I read your document and confirm that my problem (sequence number continues increaing even if no really insert in merge statement)<br />
is an Oracle bug. Thank you for your good article.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
