The basic syntactical units of the language are called tokens. 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.)
Tokens are classified as ordinary or delimiter tokens:
Spaces: A space is a sequence of one or more blank characters.
Control Characters: A control character is a
special character that is used for string alignment. The following
table contains the control characters that are handled by the database
manager:
| Control Character | EBCDIC Hex Value | UCS-2 Hex Value |
|---|---|---|
| Tab | 05 | 0009 |
| Form Feed | 0C | 000C |
| Carriage Return | 0D | 000D |
| New Line | 15 | 0085 |
| Line Feed (New line) | 25 | 000A |
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 must 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.
Here are some examples of ordinary tokens:
1 .1 +2 SELECT E 3
Here are some examples of combinations of the above ordinary tokens that, in effect, change the tokens:
1.1 .1+2 SELECTE .1E E3 SELECT1
This demonstrates why ordinary tokens must be followed by a delimiter token or a space.
Here are some examples of delimiter tokens:
, 'string' "fld1" = .
Here are some examples of combinations of the above ordinary tokens and the above delimiter tokens that, in effect, change the tokens:
1. .3
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.
If the decimal point has been defined to be the comma, as described in Decimal Point, the comma is interpreted as a decimal point in numeric constants. Here are some examples of these numeric constants:
1,2 ,1 1, 1,e1
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.
Comments: Static SQL statements can include host language comments or SQL comments. Dynamic SQL statements can include SQL comments. Either type of comment can be specified wherever a space may be specified, except within a delimiter token or between the keywords EXEC and SQL. There are two types of SQL comments:
Uppercase and Lowercase: 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:
select * from EMP where lastname = 'Smith';
is equivalent, after folding, to:
SELECT * FROM EMP WHERE LASTNAME = 'Smith';