background image
<< Using Unicode String Literals | Specifying NLS Parameters in SQL Functions >>
<< Using Unicode String Literals | Specifying NLS Parameters in SQL Functions >>

NCHAR Literal Replacement

Using Locale-Dependent Functions with NLS Parameters
6-30 Oracle Database 2 Day Developer's Guide
encoding format. For example,
UNISTR('G\0061ry')
represents
'Gary'
. The
ASCII characters are converted to the database character set and then to the
national character set. The Unicode encoding is converted directly to the national
character set.
The last two methods can be used to encode any Unicode string literals.
NCHAR Literal Replacement
As part of a SQL or PL/SQL statement, the text of any literal, with or without the
prefix
N
, is encoded in the same character set as the rest of the statement. On the client
side, the statement is in the client character set, determined by the character set
defined in the
NLS_LANG
parameter. On the server side, the statement is in the
database character set.
When the SQL or PL/SQL statement is transferred from client to the database, its
character set is converted accordingly. If the database character set does not contain all
characters used in the text literals, data is lost in this conversion. This affects
NCHAR
string literals more than the
CHAR
text literals, because the
N'
literal is designed to be
independent of the database character set, and it should be able to include any data
that the client character set allows.
To avoid data loss during conversion to an incompatible database character set, you
can use
NCHAR
literal replacement by setting the client environment variable
ORA_
NCHAR_LITERAL_REPLACE
to
TRUE
. This causes
N
literals on the client side to be
replaced by an internal format, which the database decodes to Unicode when the
statement is executed. By default,
NCHAR
literal replacement is disabled, to maintain
backward compatibility.
Using Locale-Dependent Functions with NLS Parameters
All SQL functions whose behavior depends on globalization support conventions
allow NLS parameters to be specified. These functions are
TO_CHAR
,
TO_DATE
,
TO_
NUMBER
,
NLS_UPPER
,
NLS_LOWER
,
NLS_INITCAP
, and
NLSSORT
.
Specifying NLS parameters for these functions enables the functions to be evaluated
independently of the session's NLS parameters. This feature can be important for SQL
statements that contain numbers and dates as string literals.
See Also:
Overview of Unicode
on page 6-27
Using SQL Character Data Types
on page 6-28
NCHAR Literal Replacement
on page 6-30
Oracle Database Globalization Support Guide for a complete
discussion of programming with Unicode
See Also:
Overview of Unicode
on page 6-27
Using SQL Character Data Types
on page 6-28
Using Unicode String Literals
on page 6-29
Oracle Database Globalization Support Guide for a complete
discussion of programming with Unicode