SAND CDBMS SQL Reference Guide
SAND CDBMS SQL Database Objects and Language Elements

 

Previous Topic:
Characteristics of Numeric Data Types
Chapter Index
Next Topic:
Special Constants

 

Other SAND CDBMS SQL Language Elements


Literals (Constants)

Character Strings

A character string is a series of zero or more characters. The string must be enclosed between single quotation marks ( ' ' ) when referenced in an SQL statement. For example:

'A123'
'John Smith'

Characters and strings of characters can be compared and ordered two different ways:

  1. The standard collating sequence, in which uppercase letters precede lowercase letters.
  2. The uppercase collating sequence, in which lowercase letters are converted to uppercase before comparing, allowing for sorting in “dictionary order”.

For example, using the standard collating sequence, the character string 'Smith' sorts before 'smith'. Using the uppercase collating sequence, both 'Smith' and 'smith' are converted to 'SMITH' before comparisons are made, so either string could sort before the other, since they are effectively equivalent in this case.

The standard and uppercase collating sequences can be used with either the standard or extended ASCII character sets. The standard collating sequence, using the standard ASCII repertoire, is the default; other types of collating sequences may be selected via the nconfig utility. For more information, refer to the SAND Database Configuration Tool (nconfig) chapter in the SAND CDBMS Tools Reference Guide.

Single quotation marks can be included as part of a string. However, when referencing the string in an SQL statement, the interior quotation marks should be “escaped” so that they are not interpreted as the quotation marks that delimit the string. This may be done by typing two adjacent single quotes. For example:

'Eaton''s' is interpreted as Eaton's
'''Big Blue''' is interpreted as 'Big Blue'


Numeric Constants

A numeric constant is either exact or approximate. An exact numeric constant is a decimal number. The number may include a decimal point and may also be signed. Some examples of exact numeric constants are listed below:

123
-34.873
+.873
123.873
0

An approximate numeric constant uses scientific notation: a decimal number followed by the letter E or e and a signed integer. The form, <number>E<integer>, means <number> multiplied by 10 <integer>.  Some examples of approximate numeric constants are listed below along with their exact equivalent:

 
123E4 1,230,000
-34.873e3 -34,873
+.873E0 0.873
123.873e-4 .0123873


Hexadecimal Characters

Any single character can also be specified by its hexadecimal ASCII code, including unprintable characters. A hexadecimal value is referenced using the following format:

x'<hex-code>'

For example:

x'35' (represents "5")
x'FF' (represents "ÿ")
x'0A' (represents the linefeed character)

Hexadecimal characters can be inserted into or updated in character columns, and can appear as operands in Boolean value expressions. Virtually any place that a regular character can appear, a hexadecimal character may also be used. One restriction is that hexadecimal characters cannot be specified in a SELECT list. Also, it is recommended that hexadecimal characters not be used for object names.

Note that hexadecimal values are not stored as such in a column. A value inserted as "x'35'" will display as "5" when the column contents are viewed.

 

Previous Topic:
Characteristics of Numeric Data Types
Chapter Index
Next Topic:
Special Constants