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

105 lines
7.6 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="Assignment rules for host variables in SQL statements" />
<meta name="abstract" content="SQL values are assigned to host variables during the running of FETCH, SELECT INTO, SET, and VALUES INTO statements. SQL values are assigned from host variables during the running of INSERT, UPDATE, and CALL statements." />
<meta name="description" content="SQL values are assigned to host variables during the running of FETCH, SELECT INTO, SET, and VALUES INTO statements. SQL values are assigned from host variables during the running of INSERT, UPDATE, and CALL statements." />
<meta name="DC.subject" content="host variable, assignment rule, using, concept, assignment rule, using SQL with host language, rule, assignment, SELECT INTO statement, column value, statements, SELECT INTO, INSERT statement, UPDATE statement, assignment operation, INSERT, assignment operation, UPDATE" />
<meta name="keywords" content="host variable, assignment rule, using, concept, assignment rule, using SQL with host language, rule, assignment, SELECT INTO statement, column value, statements, SELECT INTO, INSERT statement, UPDATE statement, assignment operation, INSERT, assignment operation, UPDATE" />
<meta name="DC.Relation" scheme="URI" content="rzajphostvar.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajpstringrule.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajpccsidrule.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajpnumrule.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajpdaterule.htm" />
<meta name="DC.Relation" scheme="URI" content="../db2/rbafzmstdeclvar.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="rzajpasnrule" />
<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>Assignment rules for host variables in SQL statements</title>
</head>
<body id="rzajpasnrule"><a name="rzajpasnrule"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Assignment rules for host variables in SQL statements</h1>
<div><p>SQL values are assigned to host variables during the running of
FETCH, SELECT INTO, SET, and VALUES INTO statements. SQL values are assigned
from host variables during the running of INSERT, UPDATE, and CALL statements.</p>
<div class="section"><p>All assignment operations observe the following rules: </p>
<ul><li>Numbers and strings are compatible: <ul><li>Numbers can be assigned to character or graphic string columns or host
variables.</li>
<li>Character and graphic strings can be assigned to numeric columns or numeric
host variables.</li>
</ul>
</li>
<li>All character and DBCS graphic strings are compatible with UCS-2 and UTF-16
graphic columns if conversion is supported between the CCSIDs. All graphic
strings are compatible if the CCSIDs are compatible. All numeric values are
compatible. Conversions are performed by SQL whenever necessary. All character
and DBCS graphic strings are compatible with UCS-2 and UTF-16 graphic columns
for assignment operations, if conversion is supported between the CCSIDs.
For the CALL statement, character and DBCS graphic parameters are compatible
with UCS-2 and UTF-16 parameters if conversion is supported.</li>
<li>Binary strings are only compatible with binary strings.</li>
<li>A null value cannot be assigned to a host variable that does not have
an associated indicator variable.</li>
<li>Different types of date/time values are not compatible. Dates are only
compatible with dates or string representations of dates; times are only compatible
with times or string representations of times; and timestamps are only compatible
with timestamps or string representations of timestamps.<p>A date can be assigned
only to a date column, a character column, a DBCS-open or DBCS-either column
or variable, or a character variable. The insert or update value of a date
column must be a date or a string representation of a date. A DBCS-open or
DBCS-either variable is a variable that was declared in the host language
by including the definition of an externally described file. DBCS-open
variables are also declared if the job CCSID indicates MIXED data, or the
DECLARE VARIABLE statement is used and a MIXED CCSID or the FOR MIXED DATA
clause is specified.</p>
<p>A time can be assigned only to a time column, a
character column, a DBCS-open or DBCS-either column or variable, or a character
variable. The insert or update value of a time column must be a time or a
string representation of a time.</p>
<p>A timestamp can be assigned only to
a timestamp column, a character column, a DBCS-open or DBCS-either column
or variable, or a character variable. The insert or update value of a timestamp
column must be a timestamp or a string representation of a timestamp.</p>
</li>
</ul>
</div>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="rzajpstringrule.htm">Rules for string assignment of host variables in SQL statements</a></strong><br />
This topic introduces rules regarding character string assignment.</li>
<li class="ulchildlink"><strong><a href="rzajpccsidrule.htm">Rules for CCSIDs of host variables in SQL statements</a></strong><br />
CCSIDs must be considered when you assign one character or graphic value to another. This includes the assignment of host variables. The database manager uses a common set of system services for converting SBCS data, DBCS data, MIXED data, and graphic data.</li>
<li class="ulchildlink"><strong><a href="rzajpnumrule.htm">Rules for numeric assignment of host variables in SQL statements</a></strong><br />
Rules regarding numeric assignment are as follows.</li>
<li class="ulchildlink"><strong><a href="rzajpdaterule.htm">Rules for date, time, and timestamp assignment of host variables in SQL statements</a></strong><br />
When a <strong>date</strong> is assigned to a host variable, the date is
converted to the string representation specified by the DATFMT and DATSEP
parameters of the CRTSQLxxx command.</li>
</ul>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzajphostvar.htm" title="When your program retrieves data, the values are put into data items defined by your program and specified with the INTO clause of a SELECT INTO or FETCH statement. The data items are called host variables.">Use host variables in SQL statements</a></div>
</div>
<div class="relinfo"><strong>Related information</strong><br />
<div><a href="../db2/rbafzmstdeclvar.htm">DECLARE VARIABLE</a></div>
</div>
</div>
</body>
</html>