ibm-information-center/dist/eclipse/plugins/i5OS.ic.dbp_5.4.0.1/rbaforzahftrn.htm

95 lines
5.9 KiB
HTML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="concept" />
<meta name="DC.Title" content="Add triggers" />
<meta name="abstract" content="This topic shows how to add triggers to a database file." />
<meta name="description" content="This topic shows how to add triggers to a database file." />
<meta name="DC.Relation" scheme="URI" content="rbaforzahftra.htm" />
<meta name="DC.Relation" scheme="URI" content="../cl/addpftrg.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rbaforzahftrn" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Add triggers</title>
</head>
<body id="rbaforzahftrn"><a name="rbaforzahftrn"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Add triggers</h1>
<div><p>This topic shows how to add triggers to a database file.</p>
<p>To add a trigger, follow these steps:</p>
<ol><li>Ensure that you have the proper authority and the file has the proper
data capabilities.</li>
<li><p><img src="./delta.gif" alt="Start of change" />Use one of the following methods to associate the
trigger program with a specific database file: <img src="./deltaend.gif" alt="End of change" /></p>
<ul><li><img src="./delta.gif" alt="Start of change" />Use iSeries™ Navigator to create a new file or edit the
properties of an existing file.<img src="./deltaend.gif" alt="End of change" /></li>
<li>Use the Add Physical File Trigger (ADDPFTRG) command.</li>
<li>Use the CREATE TRIGGER SQL statement.</li>
</ul>
</li>
</ol>
<div class="note"><span class="notetitle">Note:</span> If the trigger program resides in QTEMP library, the trigger program
cannot be associated with a physical file.</div>
<p><img src="./delta.gif" alt="Start of change" />After you have created the association between the trigger
program and the file, the system calls the trigger program when a change or
read operation is initiated against the database file, a member of the file,
and any logical file created over the physical file.<img src="./deltaend.gif" alt="End of change" /></p>
<p><img src="./delta.gif" alt="Start of change" />You can associate a maximum of 300 triggers with one database
file. Each insert, delete, or update operation can call multiple triggers
before and after the operation occurs. Each read operation can call multiple
triggers after the operation occurs. This topic shows how to add a trigger
to a file.<img src="./deltaend.gif" alt="End of change" /></p>
<p><img src="./delta.gif" alt="Start of change" />You can associate a maximum of three triggers with one logical
file. That is, you can create one INSTEAD OF trigger per insert, update, or
delete operation. The trigger is called instead of performing the operation.<img src="./deltaend.gif" alt="End of change" /></p>
<p>The number of triggers called after a read operation that is issued by
a query might not be equal to the number of records that are actually returned.
This is because the query might have read a different number of records, causing
a trigger to be called for each read operation, before returning the correct
number of records.</p>
<p>An SQL update operation involves a simultaneous read operation followed
by a write operation. Read triggers are not run for SQL update operations.
An update trigger should be specified to cover this read operation followed
by a write operation.</p>
<div class="section" id="rbaforzahftrn__rbaforzahftru"><a name="rbaforzahftrn__rbaforzahftru"><!-- --></a><h4 class="sectiontitle">Required authorities and data capabilities
for triggers</h4><div class="p">These required authorities are listed here:<ul><li>Object management or Alter authority to the file</li>
<li>Object operational authority to the file</li>
<li>Read data rights to the file</li>
<li>Update data rights and Object operational authority to the file if CRTPFTRG
ALWREPCHG(*YES) is specified</li>
<li>Execute authority to the file's library</li>
<li>Execute authority to the trigger program</li>
<li>Execute authority to the trigger program's library</li>
</ul>
</div>
<div class="p">The file must have appropriate data capabilities before you add
a trigger: <ul><li>CRTPF ALWUPD(*NO) conflicts with *UPDATE Trigger</li>
<li>CRTPF ALWDLT(*NO) conflicts with *DELETE Trigger</li>
</ul>
</div>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbaforzahftra.htm" title="A trigger is a set of actions that run automatically when a specified change or read operation is performed on a specified database file. On iSeries, you define a set of trigger actions in any supported high-level language.">Trigger automatic events in your database</a></div>
</div>
<div class="relref"><strong>Related reference</strong><br />
<div><a href="../cl/addpftrg.htm">Add Physical File Trigger (ADDPFTRG) command</a></div>
</div>
</div>
</body>
</html>