ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzajp_5.4.0.1/rzajpnullvar.htm

64 lines
3.8 KiB
HTML
Raw Permalink 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="Indicator variables used to set null values" />
<meta name="abstract" content="You can use an indicator variable to set a null value in a column." />
<meta name="description" content="You can use an indicator variable to set a null value in a column." />
<meta name="DC.subject" content="null value, set by indicator variable, indicator variable, used to set null value, host structure, variable, examples, used to set null value" />
<meta name="keywords" content="null value, set by indicator variable, indicator variable, used to set null value, host structure, variable, examples, used to set null value" />
<meta name="DC.Relation" scheme="URI" content="rzajpindvar.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="rzajpnullvar" />
<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>Indicator variables used to set null values</title>
</head>
<body id="rzajpnullvar"><a name="rzajpnullvar"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Indicator variables used to set null values</h1>
<div><p>You can use an indicator variable to set a null value in a column.</p>
<div class="section"><p>When processing UPDATE or INSERT statements, SQL checks the indicator
variable (if it exists). If it contains a negative value, the column value
is set to null. If it contains a value greater than -1, the associated host
variable contains a value for the column.</p>
</div>
<div class="section"><p>For example, you can specify that a value be put in a column (using
an INSERT or UPDATE statement), but you may not be sure that the value was
specified with the input data. To provide the capability to set a column to
a null value, you can write the following statement: </p>
<pre>EXEC SQL
<strong>UPDATE</strong> CORPDATA.EMPLOYEE
<strong>SET</strong> PHONENO = :NEWPHONE:PHONEIND
<strong>WHERE</strong> EMPNO = :EMPID
END-EXEC.</pre>
</div>
<div class="section"><p>When NEWPHONE contains other than a null value, set PHONEIND to
zero by preceding the statement with: </p>
<pre>MOVE 0 to PHONEIND.</pre>
</div>
<div class="section"><p>Otherwise, to tell SQL that NEWPHONE contains a null value, set
PHONEIND to a negative value, as follows: </p>
<pre>MOVE -1 TO PHONEIND.</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzajpindvar.htm" title="An indicator variable is a halfword integer variable used to indicate whether its associated host variable has been assigned a null value.">Indicator variables in applications that use SQL</a></div>
</div>
</div>
</body>
</html>