A string literal is a sequence of characters enclosed in single quotes. For example,
'Hello world' is a string literal of type CHAR. Its byte length is 11, and its character length is also 11.
A string literal is sometimes referred to as a string constant, literal string, or just as a string. In SQL Anywhere, the preferred term is string literal.
You can specify an NCHAR string literal by prefixing the quoted value with N. For example,
N'Hello world' is a string literal of type NCHAR. Its byte length is 11, and its character length is 11. The bytes within an NCHAR string
literal are interpreted using the database's CHAR character set, and then converted to NCHAR. The syntax
N'string' is a shortened form for
CAST( 'string' AS NCHAR ).
Sometimes you need to put characters into string literals that cannot be typed or entered normally. Examples include control characters (such as a new line character), single quotes (which would otherwise mark the end of the string literal), and hexadecimal byte values. For this purpose, you use an escape sequence.
The following examples show how to use escape sequences in string literals.
'First line:\nSecond line:'
You can use the same characters and escape sequences with NCHAR string literals as with CHAR string literals.
If you need to use Unicode characters that cannot be typed directly into the string literal, use the UNISTR function. See UNISTR function [String].
|Send feedback about this page via email or DocCommentXchange||Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0|