Specifies whether the length of character string parameters, columns, domains, and offsets are interpreted as characters or octets. (An octet is a group of 8 bits.)
1 – Environment
You can use the SET CHARACTER LENGTH statement: o In interactive SQL o Embedded in host language programs to be precompiled o As part of a procedure in an SQL module o In dynamic SQL as a statement to be dynamically executed
2 – Format
SET CHARACTER LENGTH -----> runtime-options ------> runtime-options --+---> 'string-literal' ------+-----> +---> parameter -------------+ +---> parameter-marker ------+
3 – Arguments
3.1 – parameter
Specifies the value of runtime-options, which must be one of the following: o OCTETS o CHARACTERS CHARACTERS specifies the length of character string parameters, columns, domains, and offsets, which are interpreted as characters. OCTETS specifies the length of character string parameters, columns, domains, and offsets, which are interpreted as octets. The default is octets.
3.2 – parameter-marker
Specifies the value of runtime-options, which must be one of the following: o OCTETS o CHARACTERS CHARACTERS specifies the length of character string parameters, columns, domains, and offsets, which are interpreted as characters. OCTETS specifies the length of character string parameters, columns, domains, and offsets, which are interpreted as octets. The default is octets.
3.3 – 'string-literal'
Specifies the value of runtime-options, which must be one of the following: o OCTETS o CHARACTERS CHARACTERS specifies the length of character string parameters, columns, domains, and offsets, which are interpreted as characters. OCTETS specifies the length of character string parameters, columns, domains, and offsets, which are interpreted as octets. The default is octets.
4 – Examples
Example 1: Setting the character length to octets SQL> set character length 'octets'; SQL> show connection current; Connection: RDB$DEFAULT_CONNECTION Default alias is RDB$DBHANDLE Default catalog name is RDB$CATALOG Default schema name is SMITH Dialect: SQLV40 Default character unit: OCTETS Keyword Rules: SQLV40 View Rules: SQLV40 Default DATE type: DATE VMS Quoting Rules: SQLV40 Optimization Level: DEFAULT Hold Cursors default: WITH HOLD PRESERVE NONE Quiet commit mode: OFF Compound transactions mode: EXTERNAL Default character set is DEC_MCS National character set is DEC_MCS Identifier character set is DEC_MCS Literal character set is DEC_MCS Display character set is UNSPECIFIED Alias RDB$DBHANDLE: Identifier character set is DEC_MCS Default character set is DEC_MCS National character set is DEC_MCS SQL> /* ***> Create two domains: one uses LATIN9, a single-octet character ***> set, and one uses KANJI a fixed multi-octet character set. ***> */ SQL> create domain LATIN9_DOM char(8) character set ISOLATIN9; SQL> create domain KANJI_DOM char(5) character set KANJI; %SQL-F-CHRUNIBAD, Number of octets is not an integral number of characters SQL> /* ***> Because KANJI is a fixed multi-octet character set, using two ***> octets for each character, you must specify the size as a ***> multiple of two. ***> */ SQL> create domain KANJI_DOM char(8) character set KANJI; SQL> show domains; User domains in database with filename MIA_CHAR_SET KANJI_DOM CHAR(8) KANJI 4 Characters, 8 Octets LATIN9_DOM CHAR(8) ISOLATIN9 8 Characters, 8 Octets SQL> Example 2: Setting the character length to characters SQL> set character length 'characters'; SQL> show connection current; Connection: RDB$DEFAULT_CONNECTION Default alias is RDB$DBHANDLE Default catalog name is RDB$CATALOG Default schema name is SMITH Dialect: SQLV40 Default character unit: CHARACTERS Keyword Rules: SQLV40 View Rules: SQLV40 Default DATE type: DATE VMS Quoting Rules: SQLV40 Optimization Level: DEFAULT Hold Cursors default: WITH HOLD PRESERVE NONE Quiet commit mode: OFF Compound transactions mode: EXTERNAL Default character set is DEC_MCS National character set is DEC_MCS Identifier character set is DEC_MCS Literal character set is DEC_MCS Display character set is UNSPECIFIED Alias RDB$DBHANDLE: Identifier character set is DEC_MCS Default character set is DEC_MCS National character set is DEC_MCS SQL> /* ***> Create two domains: one uses LATIN9, a single-octet character ***> set, and one uses KANJI a fixed multi-octet character set. ***> */ SQL> create domain LATIN9_DOM char(8) character set ISOLATIN9; SQL> create domain KANJI_DOM char(5) character set KANJI; SQL> show domains; User domains in database with filename MIA_CHAR_SET KANJI_DOM CHAR(5) KANJI 5 Characters, 10 Octets LATIN9_DOM CHAR(8) ISOLATIN9 8 Characters, 8 Octets SQL>