Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Alphanumeric literals

The syntax for an alphanumeric literal is defined as follows:


alphanumeric_literal ::=

{

    '[ character ...]'[ separator ...'[ character ...]']... |

   X'[ hex hex ]...'[ separator ...'[ hex hex ]...']...

}

hex ::= 0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f|A|B|C|D|E|F



character

Any EBCDIC character. If a string contains a single quote ('), you must duplicate this single quote. The pair of single quote characters is considered a single character (e.g. 'Variable length strings are of the type ''CHARACTER VARYING''').

hex

A hexadecimal character from the range 0-9, A-F or a-f


The data type of an alphanumeric literal is CHAR(length). length is the number of characters or pairs of hexadecimal numbers. Alphanumeric literals can be up to 256 characters long. Strings with the length 0 are permitted as literals although it is not possible to define a data type CHAR(0) (see section "Alphanumeric and national data types"). The data type is then VARCHAR(0).

The two forms of alphanumeric literal, character and hex, may be concatenated, as for instance in the German number “fünfzig” (50, 'f'||x'FD'||'nfzig') or in a concatenation with a special literal ('User:'||CURRENT_USER).

“||” must be used as the operator for the concatenation.

When strings are concatenated, either both operands must be alphanumeric (CHAR or VARCHAR) or both must be of the national type (NCHAR or NVARCHAR), see the section "Compatibility between data types".

separator

Separator that separates two substrings from each other (see section "Separators"). If an alphanumeric literal consists of two or more substrings, adjacent substrings must be separated by one or more separators. At least one of the separators must be a transition point to the next row.

The result of an alphanumeric literal comprising substrings is the concatenation of the substrings involved without the operator for concatenation having to be written for this purpose.


Example

The following alphanumeric literal consists of three substrings:

'Separated '     -- First substring
'by table '      -- Second substring
'and bed'        -- Third substring

The result is the string 'Separated by table and bed'.