<?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: Can I commit a transaction inside a database trigger?</title>
	<atom:link href="http://oraqa.com/2006/02/16/can-i-commit-a-transaction-inside-a-database-trigger/feed/" rel="self" type="application/rss+xml" />
	<link>http://oraqa.com/2006/02/16/can-i-commit-a-transaction-inside-a-database-trigger/</link>
	<description>Oracle Question and Answer</description>
	<lastBuildDate>Tue, 06 Jul 2010 14:28:12 -0600</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Karl Reitschuster</title>
		<link>http://oraqa.com/2006/02/16/can-i-commit-a-transaction-inside-a-database-trigger/comment-page-1/#comment-136</link>
		<dc:creator>Karl Reitschuster</dc:creator>
		<pubDate>Fri, 17 Feb 2006 10:55:09 +0000</pubDate>
		<guid isPermaLink="false">http://oraqa.com/2006/02/16/can-i-commit-a-transaction-inside-a-database-trigger/#comment-136</guid>
		<description>Hi,
is use autonomous transactions to log errors/warnings/infos independent if the main transaction fails or not (see for WriteEventlog):

&lt;pre&gt;

  PROCEDURE Logapperror(p_Appcode                 IN Eventlog.Appcode%TYPE,
                        p_Eventmessage            IN Eventlog.Eventmessage%TYPE,
                        p_Modul                   IN Eventlog.Modul%TYPE,
                        p_Method                  IN Eventlog.Method%TYPE,
                        p_Section                 IN Eventlog.Section%TYPE,
                        p_Raise_Application_Error IN BOOLEAN,
                        p_Objectid                IN t_Objectid,
                        p_Objectentity            IN t_Objectentity) IS
  
  BEGIN
  
    Initentry(p_Eventmessage,
              p_Modul,
              p_Method,
              p_Severity =&gt; c_Severity_Error,
              p_Component =&gt; c_Component_App,
              p_Objectid =&gt; p_Objectid,
              p_Objectentity =&gt; p_Objectentity);
  
    Eventlog_Entry.Appcode := p_Appcode;
    Eventlog_Entry.Section := Substr(p_Section,
                                     1,
                                     64);
  
    Writeeventlog;
  
    IF (p_Raise_Application_Error) THEN
      Raise_Application_Error(-20001,
                              p_Modul &#124;&#124; &#039;.&#039; &#124;&#124; p_Method &#124;&#124; &#039; : &#039; &#124;&#124;
                              p_Eventmessage);
    
    END IF;
  END Logapperror;
&lt;/pre&gt;

&lt;pre&gt;
  PROCEDURE Writeeventlog IS
    PRAGMA AUTONOMOUS_TRANSACTION;
  BEGIN
    INSERT INTO Eventlog
    VALUES Eventlog_Entry;
    COMMIT;
  EXCEPTION
    WHEN OTHERS THEN
      -- Housten we have a problem
      ROLLBACK;
      RAISE;
  END Writeeventlog;

&lt;/pre&gt;

i would not use this feature to modify application data via trigger and commit them. There must be a better way/design to avoid this.
Karl</description>
		<content:encoded><![CDATA[<p>Hi,<br />
is use autonomous transactions to log errors/warnings/infos independent if the main transaction fails or not (see for WriteEventlog):</p>
<pre>

  PROCEDURE Logapperror(p_Appcode                 IN Eventlog.Appcode%TYPE,
                        p_Eventmessage            IN Eventlog.Eventmessage%TYPE,
                        p_Modul                   IN Eventlog.Modul%TYPE,
                        p_Method                  IN Eventlog.Method%TYPE,
                        p_Section                 IN Eventlog.Section%TYPE,
                        p_Raise_Application_Error IN BOOLEAN,
                        p_Objectid                IN t_Objectid,
                        p_Objectentity            IN t_Objectentity) IS

  BEGIN

    Initentry(p_Eventmessage,
              p_Modul,
              p_Method,
              p_Severity =&gt; c_Severity_Error,
              p_Component =&gt; c_Component_App,
              p_Objectid =&gt; p_Objectid,
              p_Objectentity =&gt; p_Objectentity);

    Eventlog_Entry.Appcode := p_Appcode;
    Eventlog_Entry.Section := Substr(p_Section,
                                     1,
                                     64);

    Writeeventlog;

    IF (p_Raise_Application_Error) THEN
      Raise_Application_Error(-20001,
                              p_Modul || '.' || p_Method || ' : ' ||
                              p_Eventmessage);

    END IF;
  END Logapperror;
</pre>
<pre>
  PROCEDURE Writeeventlog IS
    PRAGMA AUTONOMOUS_TRANSACTION;
  BEGIN
    INSERT INTO Eventlog
    VALUES Eventlog_Entry;
    COMMIT;
  EXCEPTION
    WHEN OTHERS THEN
      -- Housten we have a problem
      ROLLBACK;
      RAISE;
  END Writeeventlog;
</pre>
<p>i would not use this feature to modify application data via trigger and commit them. There must be a better way/design to avoid this.<br />
Karl</p>
]]></content:encoded>
	</item>
</channel>
</rss>
