SET NAMES (Reference)

From InterBase
Jump to: navigation, search

Go Up to Statement and Function Reference (Language Reference Guide)


Specifies an active character set to use for subsequent database attachments. Available in gpre, and isql.

SET NAMES [charset | :var];
Important: In SQL statements passed to DSQL, omit the terminating semicolon. In embedded applications written in C and C++, and in isql, the semicolon is a terminating symbol for the statement, so it must be included.
Argument Description

<charset>

Name of a character set that identifies the active character set for a given process; default: NONE.

<var>

Host variable containing string identifying a known character set name

  • Must be declared as a character set name.
  • SQL only.

Description: SET NAMES specifies the character set to use for subsequent database attachments in an application. It enables the server to translate between the default character set for a database on the server and the character set used by an application on the client.

SET NAMES must appear before the SET DATABASE and CONNECT statements are affected.

Tip: Use a host-language variable with SET NAMES in an embedded application to specify a character set interactively.

For a complete list of character sets recognized by InterBase, see Character Sets and Collation Orders. Choice of character sets limits possible collation orders to a subset of all available collation orders. Given a specific character set, a specific collation order can be specified when data is selected, inserted, or updated in a column.

Important: If you do not specify a default character set, the character set defaults to NONE. Using character set NONE means that there is no character set assumption for columns; data is stored and retrieved just as you originally entered it. You can load any character set into a column defined with NONE, but you cannot load that same data into another column that has been defined with a different character set. No transliteration is performed between the source and destination character sets, so in most cases, errors occur during assignment.

Example: The following statements demonstrate the use of SET NAMES in an embedded SQL application:

EXEC SQL
SET NAMES ISO8859_1;
EXEC SQL
SET DATABASE DB1 = 'employee.ib';
EXEC SQL
CONNECT;

The next statements demonstrate the use of SET NAMES in isql:

SET NAMES LATIN1;
CONNECT 'employee.ib';

See Also