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

79 lines
4.9 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<?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="WITH CASCADED CHECK OPTION" />
<meta name="abstract" content="The WITH CASCADED CHECK OPTION clause specifies that every row that is inserted or updated through the view must conform to the definition of the view." />
<meta name="description" content="The WITH CASCADED CHECK OPTION clause specifies that every row that is inserted or updated through the view must conform to the definition of the view." />
<meta name="DC.subject" content="CREATE VIEW statement, WITH CASCADED CHECK OPTION, view, WITH CASCADED CHECK" />
<meta name="keywords" content="CREATE VIEW statement, WITH CASCADED CHECK OPTION, view, WITH CASCADED CHECK" />
<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="rbafywithcascade" />
<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>WITH CASCADED CHECK OPTION</title>
</head>
<body id="rbafywithcascade"><a name="rbafywithcascade"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">WITH CASCADED CHECK OPTION</h1>
<div><p>The WITH CASCADED CHECK OPTION clause specifies that
every row that is inserted or updated through the view must conform to the
definition of the view.</p>
<div class="section"><p>In addition, the search conditions of all dependent views are
checked when a row is inserted or updated. If a row does not conform to the
definition of the view, that row cannot be retrieved using the view.</p>
</div>
<div class="section"><p>For example, consider the following updatable view: </p>
<pre> <strong>CREATE VIEW</strong> V1 <strong>AS SELECT</strong> COL1
<strong>FROM</strong> T1 <strong>WHERE</strong> COL1 &gt; 10</pre>
</div>
<div class="section"><p>Because no WITH CHECK OPTION is specified, the following INSERT
statement is successful even though the value being inserted does not meet
the search condition of the view. </p>
<pre> <strong>INSERT INTO</strong> V1 <strong>VALUES</strong> (5)</pre>
</div>
<div class="section"><p>Create another view over V1, specifying the WITH CASCADED CHECK
OPTION: </p>
<pre> <strong>CREATE VIEW</strong> V2 <strong>AS SELECT</strong> COL1
<strong>FROM</strong> V1 <strong>WITH CASCADED CHECK OPTION</strong></pre>
</div>
<div class="section"><p>The following INSERT statement fails because it produces a row
that does not conform to the definition of V2: </p>
<pre> <strong>INSERT INTO</strong> V2 <strong>VALUES</strong> (5)</pre>
</div>
<div class="section"><p>Consider one more view created over V2: </p>
<pre> <strong>CREATE VIEW</strong> V3 <strong>AS SELECT</strong> COL1
<strong>FROM</strong> V2 <strong>WHERE</strong> COL1 &lt; 100</pre>
</div>
<div class="section"><p>The following INSERT statement fails only because V3 is dependent
on V2, and V2 has a WITH CASCADED CHECK OPTION. </p>
<pre> <strong>INSERT INTO</strong> V3 <strong>VALUES</strong> (5)</pre>
</div>
<div class="section"><p>However, the following INSERT statement is successful because
it conforms to the definition of V2. Because V3 does not have a WITH CASCADED
CHECK OPTION, it does not matter that the statement does not conform to the
definition of V3. </p>
<pre> <strong>INSERT INTO</strong> V3 <strong>VALUES</strong> (200)</pre>
</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>