Edit D:\app\Administrator\product\11.2.0\dbhome_1\oc4j\j2ee\oc4j_applications\applications\em\em\online_help\tdddg\tdddg_deploying008.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <script src="./callback.js" type="text/javascript"></script> <noscript>Your browser does not support JavaScript. This help page requires JavaScript to render correctly.</noscript> </head> <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.1.1 Build 005" /> <meta name="date" content="2009-04-21T9:46:25Z" /> <meta name="robots" content="noarchive" /> <meta name="doctitle" content="Editing Installation Script Files that Create Triggers" /> <meta name="relnum" content="11g Release 2 (11.2)" /> <meta name="partnum" content="E10766-01" /> <link rel="copyright" href="./dcommon/html/cpyr.htm" title="Copyright" type="text/html" /> <link rel="stylesheet" href="./dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" /> <link rel="contents" href="toc.htm" title="Contents" type="text/html" /> <link rel="prev" href="tdddg_deploying007.htm" title="Previous" type="text/html" /> <link rel="next" href="tdddg_deploying009.htm" title="Next" type="text/html" /> <title>Editing Installation Script Files that Create Triggers</title> </head> <body> <div class="zz-skip-header"><a href="#BEGIN">Skip Headers</a></div> <table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%"> <col width="86%" /> <col width="*" /> <tr valign="bottom"> <td align="left"></td> <td align="center"><a href="tdddg_deploying007.htm"><img width="24" height="24" src="./dcommon/gifs/leftnav.gif" alt="Previous" /><br /> <span class="icon">Previous</span></a> </td> <td align="center"><a href="tdddg_deploying009.htm"><img width="24" height="24" src="./dcommon/gifs/rightnav.gif" alt="Next" /><br /> <span class="icon">Next</span></a></td> </tr> </table> <p><a id="BABJCJIJ" name="BABJCJIJ"></a><a id="TDDDG74100" name="TDDDG74100"></a></p> <div class="sect2"><!-- infolevel="all" infotype="General" --> <h1>Editing Installation Script Files that Create Triggers</h1> <a name="BEGIN" id="BEGIN"></a> <p>If your application has a <code>BEFORE</code> <code>INSERT</code> <a id="sthref717" name="sthref717"></a><a id="sthref718" name="sthref718"></a><a id="sthref719" name="sthref719"></a><a id="sthref720" name="sthref720"></a><a id="sthref721" name="sthref721"></a>trigger on a source table, and you <span class="italic">will</span> insert the data from that source table into the corresponding new table, then you must decide if you want the trigger to fire before each <code>INSERT</code> statement in the installation script file inserts data into the new table.</p> <p>For example, in the sample application, <code>NEW_EVALUATION_TRIGGER</code> fires before a row is inserted into the <code>EVALUATIONS</code> table, and generates the unique number for the primary key of that row, using <code>EVALUATIONS_SEQ</code>. The trigger fires once for each row affected by the triggering <code>INSERT</code> statement. (<code>NEW_EVALUATION_TRIGGER</code> is created in <a href="tdddg_triggers005.htm#BABCGBBD">"Tutorial: Creating a Trigger that Generates a Primary Key for a Row Before It Is Inserted"</a>.)</p> <p>The source <code>EVALUATIONS</code> table is populated with primary keys. If you do not want the installation script to put new primary key values in the new <code>EVALUATIONS</code> table, then you must edit the <code>CREATE</code> <code>TRIGGER</code> statement in the installation script file as shown in bold:</p> <pre xml:space="preserve" class="oac_no_warn"> CREATE OR REPLACE TRIGGER NEW_EVALUATION_TRIGGER BEFORE INSERT ON EVALUATIONS FOR EACH ROW BEGIN <span class="bold">IF :NEW.evaluation_id IS NULL THEN</span> :NEW.evaluation_id := evaluations_seq.NEXTVAL <span class="bold">END IF;</span> END; </pre> <p>Also, check the current value of the sequence. If it not is greater than the maximum value in the primary key column, make it greater.</p> <p>You can edit the installation script file in the SQL Worksheet or any text editor.</p> <p>Two alternatives to editing the installation script file are:</p> <ul> <li> <p>Change the trigger definition in the source file and then re-create the installation script file.</p> <p>For information about changing triggers, see <a href="tdddg_triggers008.htm#CHDBBCAJ">"Changing Triggers"</a>.</p> </li> <li> <p>Disable the trigger before running the data installation script file, and then re-enable it afterward.</p> <p>For information about disabling and enabling triggers, see <a href="tdddg_triggers009.htm#CHDHIADD">"Disabling and Enabling Triggers"</a>.</p> </li> </ul> <p>If your application uses <a id="sthref722" name="sthref722"></a><a id="sthref723" name="sthref723"></a><a id="sthref724" name="sthref724"></a>triggers to populate auditing columns (such as <code>CREATED_ON</code> and <code>CREATED_BY</code>), you must preserve your source table data by having the trigger set a new value only if the current value is null, with code like this:</p> <pre xml:space="preserve" class="oac_no_warn"> IF :NEW.CREATED_ON IS NULL THEN :NEW.CREATED_ON := SYSDATE; END IF; </pre> <div class="helpinfonotealso"> <h2>Related Topics</h2> <p><a href="tdddg_triggers002.htm#BABDAGJJ">Creating Triggers</a></p> <p><a href="tdddg_deploying005.htm#BABIIBHE">Creating Installation Script Files</a></p> </div> </div> <!-- class="sect2" --> <!-- Start Footer --> <div class="footer"> <table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%"> <col width="86%" /> <col width="*" /> <tr> <td align="left"><span class="copyrightlogo">Copyright © 1996, 2009, Oracle and/or its affiliates. All rights reserved.</span><br /> <a href="./dcommon/html/cpyr.htm"><span class="copyrightlogo">Legal Notices</span></a></td> <td align="center"><a href="tdddg_deploying007.htm"><img width="24" height="24" src="./dcommon/gifs/leftnav.gif" alt="Previous" /><br /> <span class="icon">Previous</span></a> </td> <td align="center"><a href="tdddg_deploying009.htm"><img width="24" height="24" src="./dcommon/gifs/rightnav.gif" alt="Next" /><br /> <span class="icon">Next</span></a></td> </tr> </table> </div> <!-- class="footer" --> </body> </html>
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de