ibm-information-center/dist/eclipse/plugins/i5OS.ic.db2_5.4.0.1/rbafzmstch2tok.htm

153 lines
8.8 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 xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="dc.language" scheme="rfc1766" 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. -->
<meta name="dc.date" scheme="iso8601" content="2005-09-19" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<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="keywords" content="tokens, SQL (Structured Query Language),
tokens in SQL, string delimiter, SQL, comment, control characters, limits,
identifiers" />
<title>Tokens</title>
<link rel="stylesheet" type="text/css" href="ibmidwb.css" />
<link rel="stylesheet" type="text/css" href="ic.css" />
</head>
<body>
<a id="Top_Of_Page" name="Top_Of_Page"></a><!-- Java sync-link -->
<script language = "Javascript" src = "../rzahg/synch.js" type="text/javascript"></script>
<a name="ch2tok"></a>
<h2 id="ch2tok"><a href="rbafzmst02.htm#ToC_82">Tokens</a></h2><a id="idx225" name="idx225"></a><a id="idx226" name="idx226"></a><a id="idx227" name="idx227"></a><a id="idx228" name="idx228"></a><a id="idx229" name="idx229"></a>
<p>The basic syntactical units of the language are called <span class="italic">tokens</span>. A token consists of one or more characters, excluding blanks,
control characters, and characters within a string constant or delimited identifier.
(These terms are defined later.)</p>
<p>Tokens are classified as <span class="italic">ordinary</span> or <span class="italic">delimiter</span> tokens: </p>
<ul>
<li>An <span class="italic">ordinary token</span> is a numeric constant, an ordinary
identifier, a host identifier, or a keyword.
<p><span class="italic">Examples</span> </p>
<pre class="xmp"> 1 .1 +2 SELECT E 3</pre></li>
<li>A <span class="italic">delimiter token</span> is a string constant, a delimited
identifier, an operator symbol, or any of the special characters shown in
the syntax diagrams. A question mark (?) is also a delimiter token when it
serves as a parameter marker, as explained under <a href="rbafzmstpreph2.htm#preph2">PREPARE</a>.
<p><span class="italic">Examples</span> </p>
<pre class="xmp"> , 'Myst Island' "fld1" = .</pre></li></ul>
<p><span class="bold">Spaces</span>: A <span class="italic">space</span> is a sequence
of one or more blank characters.</p>
<p><span class="bold">Control Characters</span>: A <span class="italic">control
character</span> is a special character that is used for string alignment. The
following table contains the control characters that are handled by the database
manager:</p>
<a name="table"></a>
<table id="table" width="100%" summary="" border="1" frame="border" rules="rows">
<caption>Table 1. Control Characters</caption>
<thead valign="bottom">
<tr>
<th id="wq63" width="50%" align="left" valign="bottom">Control Character <a id="idx230" name="idx230"></a> <a id="idx231" name="idx231"></a></th>
<th id="wq64" width="25%" align="left" valign="bottom">EBCDIC Hex Value</th>
<th id="wq65" width="25%" align="left" valign="bottom">UTF-16 or UCS-2 Hex Value</th>
</tr>
</thead>
<tbody valign="top">
<tr>
<td align="left" valign="top" headers="wq63">Tab</td>
<td align="left" valign="top" headers="wq64">05</td>
<td align="left" valign="top" headers="wq65">0009</td>
</tr>
<tr>
<td align="left" valign="top" headers="wq63">Form Feed</td>
<td align="left" valign="top" headers="wq64">0C</td>
<td align="left" valign="top" headers="wq65">000C</td>
</tr>
<tr>
<td align="left" valign="top" headers="wq63">Carriage Return</td>
<td align="left" valign="top" headers="wq64">0D</td>
<td align="left" valign="top" headers="wq65">000D</td>
</tr>
<tr>
<td align="left" valign="top" headers="wq63">New Line</td>
<td align="left" valign="top" headers="wq64">15</td>
<td align="left" valign="top" headers="wq65">0085</td>
</tr>
<tr>
<td align="left" valign="top" headers="wq63">Line Feed (New line)</td>
<td align="left" valign="top" headers="wq64">25</td>
<td align="left" valign="top" headers="wq65">000A</td>
</tr>
<tr>
<td headers="wq63">DBCS Space</td>
<td headers="wq64">&mdash;</td>
<td headers="wq65">3000</td>
</tr>
</tbody>
</table>
<p>Tokens, other than string constants and certain delimited identifiers,
must not include a control character or space. A control character or space
can follow a token. A delimiter token, a control character, or a space <span class="italic">must</span> follow every ordinary token. If the syntax does not
allow a delimiter token to follow an ordinary token, then a control character
or a space must follow that ordinary token. The following examples illustrate
the rule that is stated in this paragraph.</p>
<p>Here are some examples of combinations of the above ordinary tokens that,
in effect, change the tokens: </p>
<pre class="xmp"> 1.1 .1+2 SELECTE .1E E3 SELECT1</pre>
<p>This demonstrates why ordinary tokens must be followed by a delimiter token
or a space.</p>
<p>Here are some examples of combinations of the above ordinary tokens and
the above delimiter tokens that, in effect, change the tokens: </p>
<pre class="xmp"> 1. .3</pre>
<p>The period (.) is a delimiter token when it is used as a separator in the
qualification of names. Here the dot is used in combination with an ordinary
token of a numeric constant. Thus, the syntax does not allow an ordinary
token to be followed by a delimiter token. Instead, the ordinary token must
be followed by a space.</p>
<p>If the decimal point has been defined to be the comma, as described in <a href="rbafzmstch2cons.htm#datsep">Decimal point</a>, the comma is interpreted as a decimal point in numeric constants.
Here are some examples of these numeric constants: </p>
<pre class="xmp"> 1,2 ,1 1, 1,e1</pre>
<p>If '1,2' and '1,e1' are meant to be two items, both the
ordinary token (1) and the delimiter token (,) must be followed by a space,
to prevent the comma from being interpreted as a decimal point. Although
the comma is usually a delimiter token, the comma is part of the number when
it is interpreted as a decimal point. Therefore, the syntax does not allow
an ordinary token (1) to be followed by a delimiter token (,). Instead, an
ordinary token must be followed by a space.</p>
<p><span class="bold">Comments</span>: Dynamic SQL statements can include
SQL comments. Static SQL statements can include host language comments or
SQL comments. Comments may be specified wherever a space may be specified,
except within a delimiter token or between the keywords EXEC and SQL. In Java&trade;, SQL comments are not allowed within embedded Java expressions.
There are two types of SQL comments: </p>
<dl>
<dt class="bold">simple comments</dt>
<dd>Simple comments are introduced by two consecutive hyphens (--). Simple
comments cannot continue past the end of the line. For more information, see <a href="rbafzmstsqcomm.htm#sqcomm">SQL comments</a>.
</dd>
<dt class="bold">bracketed comments</dt>
<dd>Bracketed comments are introduced by /* and end with */. A bracketed
comment can continue past the end of the line. For more information, see <a href="rbafzmstsqcomm.htm#sqcomm">SQL comments</a>.
</dd>
</dl>
<p><span class="bold">Uppercase and Lowercase</span>: Lowercase letters used in
an ordinary token other than a C host variable will be folded to uppercase.
Delimiter tokens are never folded to uppercase. Thus, the statement: </p>
<pre class="xmp"> <span class="bold">select * from</span> EMP <span class="bold">where</span> lastname = 'Smith';</pre>
<p>is equivalent, after folding, to: </p>
<a name="ref2x1"></a>
<pre id="ref2x1" class="xmp"> <span class="bold">SELECT * FROM</span> EMP <span class="bold">WHERE</span> LASTNAME = 'Smith';</pre>
<hr /><br />
[ <a href="#Top_Of_Page">Top of Page</a> | <a href="rbafzmstch2char.htm">Previous Page</a> | <a href="rbafzmstch2iden.htm">Next Page</a> | <a href="rbafzmst02.htm#wq1">Contents</a> |
<a href="rbafzmstindex.htm#index">Index</a> ]
<a id="Bot_Of_Page" name="Bot_Of_Page"></a>
</body>
</html>