SQL Reference

Restrictions Using Varying-Length Character Strings

Special restrictions apply to an expression resulting in a varying-length string data type whose maximum length is greater than 255 bytes; such expressions are not permitted in:

In addition to the restrictions listed above, expressions resulting in LONG VARCHAR, CLOB data types or structured type columns are not permitted in:

The functions in the SYSFUN schema taking a VARCHAR as an argument will not accept VARCHARs greater than 4 000 bytes long as an argument. However, many of these functions also have an alternative signature accepting a CLOB(1M). For these functions the user may explicitly cast the greater than 4 000 VARCHAR strings into CLOBs and then recast the result back into VARCHARs of desired length.

NUL-Terminated Character Strings

NUL-terminated character strings found in C are handled differently, depending on the standards level of the precompile option. See the C language specific section in the Application Development Guide for more information on the treatment of NUL-terminated character strings.

Character Subtypes

Each character string is further defined as one of:

Bit data
Data that is not associated with a code page.

SBCS data
Data in which every character is represented by a single byte.

Mixed data
Data that may contain a mixture of characters from a single-byte character set (SBCS) and a multi-byte character set (MBCS).

SBCS and MBCS Considerations

SBCS data is supported only in a SBCS database. Mixed data is only supported in an MBCS database.

Graphic Strings

A graphic string is a sequence of bytes which represents double-byte character data. The length of the string is the number of double-byte characters in the sequence. If the length is zero, the value is called the empty string. This value should not be confused with the null value.

Graphic strings are not validated to ensure that their values contain only double-byte character code points. 15 Rather, the database manager assumes that double-byte character data is contained within graphic data fields. The database manager checks that a graphic string value is an even number of bytes in length.

A graphic string data type may be fixed length or varying length; the semantics of fixed length and varying length are analogous to those defined for character string data types.

Fixed-Length Graphic Strings

All values of a fixed-length graphic string column have the same length, which is determined by the length attribute of the column. The length attribute must be between 1 and 127, inclusive.

Varying-Length Graphic Strings

Varying-length graphic strings are of three types: VARGRAPHIC, LONG VARGRAPHIC, and DBCLOB.

Special restrictions apply to an expression resulting in a varying-length graphic string data type whose maximum length is greater than 127. Those restrictions are the same as specified in Restrictions Using Varying-Length Character Strings.

NUL-Terminated Graphic Strings

NUL-terminated graphic strings found in C are handled differently, depending on the standards level of the precompile option. See the C language specific section in the Application Development Guide for more information on the treatment of NUL-terminated graphic strings.

This data type cannot be created in a table. It can only be used to insert data into and retrieve data from the database.

Binary String

A binary string is a sequence of bytes. Unlike a character string which usually contains text data, a binary string is used to hold non-traditional data such as pictures. Note that character strings of the 'bit data' subtype may be used for similar purposes, but the two data types are not compatible. The BLOB scalar function can be used to cast a character for bit string to a binary string. The length of a binary string is the number of bytes. It is not associated with a code page. Binary strings have the same restrictions as character strings (see Restrictions Using Varying-Length Character Strings for details).

Numbers

All numbers have a sign and a precision. The precision is the number of bits or digits excluding the sign. The sign is considered positive if the value of a number is zero.

Small Integer (SMALLINT)

A small integer is a two byte integer with a precision of 5 digits. The range of small integers is -32 768 to 32 767.

Large Integer (INTEGER)

A large integer is a four byte integer with a precision of 10 digits. The range of large integers is -2 147 483 648 to +2 147 483 647.

Big Integer (BIGINT)

A big integer is an eight byte integer with a precision of 19 digits. The range of big integers is -9 223 372 036 854 775 808 to +9 223 372 036 854 775 807.

Single-Precision Floating-Point (REAL)

A single-precision floating-point number is a 32 bit approximation of a real number. The number can be zero or can range from -3.402E+38 to -1.175E-37, or from 1.175E-37 to 3.402E+38.

Double-Precision Floating-Point (DOUBLE or FLOAT)

A double-precision floating-point number is a 64 bit approximation of a real number. The number can be zero or can range from -1.79769E+308 to -2.225E-307, or from 2.225E-307 to 1.79769E+308.

Decimal (DECIMAL or NUMERIC)

A decimal value is a packed decimal number with an implicit decimal point. The position of the decimal point is determined by the precision and the scale of the number. The scale, which is the number of digits in the fractional part of the number, cannot be negative or greater than the precision. The maximum precision is 31 digits. For information on packed decimal representation, see Packed Decimal Numbers.

All values of a decimal column have the same precision and scale. The range of a decimal variable or the numbers in a decimal column is -n to +n, where the absolute value of n is the largest number that can be represented with the applicable precision and scale. The maximum range is -10**31+1 to 10**31-1.


Footnotes:

15
The exception to this rule is an application precompiled with the WCHARTYPE CONVERT option. In this case, validation does occur. See "Programming in C and C++" in the Application Development Guide for details.


[ Top of Page | Previous Page | Next Page ]