ibm-information-center/dist/eclipse/plugins/i5OS.ic.sqlp_5.4.0.1/rbafyexcascade.htm

95 lines
5.4 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="reference" />
<meta name="DC.Title" content="Cascaded check option" />
<meta name="abstract" content="This example illustrates using the Cascaded check option." />
<meta name="description" content="This example illustrates using the Cascaded check option." />
<meta name="DC.subject" content="examples, view WITH LOCAL CHECK OPTION, view WITH CASCADED CHECK OPTION" />
<meta name="keywords" content="examples, view WITH LOCAL CHECK OPTION, view WITH CASCADED CHECK OPTION" />
<meta name="DC.Relation" scheme="URI" content="rbafywcohdg.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="rbafyexcascade" />
<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>Cascaded check option</title>
</head>
<body id="rbafyexcascade"><a name="rbafyexcascade"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Cascaded check option</h1>
<div><p>This example illustrates using the Cascaded check
option.</p>
<div class="section"><p>Use the following table and views: </p>
<pre> <strong>CREATE TABLE</strong> T1 (COL1 <strong>CHAR</strong>(10))
<strong>CREATE VIEW</strong> V1 <strong>AS SELECT</strong> COL1
<strong>FROM</strong> T1 <strong>WHERE</strong> COL1 <strong>LIKE</strong> 'A%'
<strong>CREATE VIEW</strong> V2 <strong>AS SELECT</strong> COL1
<strong>FROM</strong> V1 <strong>WHERE</strong> COL1 <strong>LIKE</strong> '%Z'
<strong>WITH LOCAL CHECK OPTION</strong>
<strong>CREATE VIEW</strong> V3 <strong>AS SELECT</strong> COL1
<strong>FROM</strong> V2 <strong>WHERE</strong> COL1 <strong>LIKE</strong> 'AB%'
<strong>CREATE VIEW</strong> V4 <strong>AS SELECT</strong> COL1
<strong>FROM</strong> V3 <strong>WHERE</strong> COL1 <strong>LIKE</strong> '%YZ'
<strong>WITH CASCADED CHECK OPTION</strong>
<strong>CREATE VIEW</strong> V5 <strong>AS SELECT</strong> COL1
<strong>FROM</strong> V4 <strong>WHERE</strong> COL1 <strong>LIKE</strong> 'ABC%'</pre>
</div>
<div class="section"><p>Different search conditions are going to be checked depending
on which view is being operated on with an INSERT or UPDATE. </p>
<ul><li>If V1 is operated on, no conditions are checked because V1 does not have
a WITH CHECK OPTION specified.</li>
<li>If V2 is operated on, <ul><li>COL1 must end in the letter Z, but it doesn't need to start with the letter
A. This is because the check option is LOCAL, and view V1 does not have a
check option specified.</li>
</ul>
</li>
<li>If V3 is operated on, <ul><li>COL1 must end in the letter Z, but it does not need to start with the
letter A. V3 does not have a check option specified, so its own search condition
must not be met. However, the search condition for V2 must be checked since
V3 is defined on V2, and V2 has a check option.</li>
</ul>
</li>
<li>If V4 is operated on, <ul><li>COL1 must start with 'AB', and must end with 'YZ'. Because V4 has the
WITH CASCADED CHECK OPTION specified, every search condition for every view
on which V4 is dependent must be checked.</li>
</ul>
</li>
<li>If V5 is operated on, <ul><li>COL1 must start with 'AB', but not necessarily 'ABC'. This is because
V5 does not specify a check option, so its own search condition does not need
to be checked. However, because V5 is defined on V4, and V4 had a cascaded
check option, every search condition for V4, V3, V2, and V1 must be checked.
That is, COL1 must start with 'AB' and end with 'YZ'.</li>
</ul>
</li>
</ul>
</div>
<div class="section"><p>If V5 were created WITH LOCAL CHECK OPTION, operating on V5 means
that COL1 must start with 'ABC' and end with 'YZ'. The LOCAL CHECK OPTION
adds the additional requirement that the third character must be a 'C'.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbafywcohdg.htm" title="WITH CHECK OPTION is an optional clause on the CREATE VIEW statement that specifies the level of checking to be done when inserting or updating data through a view. If the option is specified, every row that is inserted or updated through the view must conform to the definition of that view.">WITH CHECK OPTION on a View</a></div>
</div>
</div>
</body>
</html>