Oracle SQL Developer
Oracle SQL Developer
Oracle SQL Developer
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Locale-Dependent <strong>SQL</strong> Functions with Optional NLS Parameters11.3.3 Unicode String LiteralsYou can input Unicode string literals in <strong>SQL</strong> and PL/<strong>SQL</strong> as follows:■■Put a prefix N before a string literal that is enclosed with single quote marks. Thisexplicitly indicates that the following string literal is an NCHAR string literal. Forexample, N'résumé' is an NCHAR string literal. This has the same limitation asenclosing the string literal with single quote marks, where the data can be lostduring the conversion to the server's database character set. To avoid the potentialloss of data, you can set the environment variable ORA_NCHAR_LITERAL_REPLACE to true. This will transparently replace the N' internally and preservethe text literal for <strong>SQL</strong> processing. By default, this environment variable is set tofalse to maintain backward compatibility.Use the NCHR(n) <strong>SQL</strong> function, which returns a unit of character code in thenational character set, which is AL16UTF16 or UTF8. The result of concatenatingseveral NCHR(n) functions is NVARCHAR2 data. In this way, you can bypass theclient and server character set conversions and create an NVARCHAR2 stringdirectly. For example, NCHR(32) represents a blank character.Because NCHR(n) is associated with the national character set, portability of theresulting value is limited to applications that run with the same national characterset. If this is a concern, then use the UNISTR function to remove portabilitylimitations.■ Use the UNISTR('string') <strong>SQL</strong> function. UNISTR('string') converts a string tothe national character set. To ensure portability and to preserve data, include onlyASCII characters and Unicode encoding in the following form: \xxxx, wherexxxx is the hexadecimal value of a character code value in UTF-16 encodingformat. For example, UNISTR('G\0061ry') represents 'Gary'. The ASCIIcharacters are converted to the database character set and then to the nationalcharacter set. The Unicode encoding is converted directly to the national characterset.The last two methods can be used to encode any Unicode string literals.11.4 Locale-Dependent <strong>SQL</strong> Functions with Optional NLS ParametersAll <strong>SQL</strong> functions whose behavior depends on globalization support conventionsallow NLS parameters to be specified. These functions are:TO_CHARTO_DATETO_NUMBERNLS_UPPERNLS_LOWERNLS_INITCAPNLSSORTExplicitly specifying the optional NLS parameters for these functions enables thefunctions to be evaluated independently of the session's NLS parameters. This featurecan be important for <strong>SQL</strong> statements that contain numbers and dates as string literals.For example, the following query is evaluated correctly if the language specified fordates is AMERICAN:SELECT last_name FROM employees WHERE hire_date > '01-JAN-1999';Working in a Global Environment 11-21