Literals (Constants)
A literal — or constant — is a value that is supplied directly in an SQL statement, not derived from an expression, a parameter, a column reference nor a variable.It can be a string or a number.
A literal — or constant — is a value that is supplied directly in an SQL statement, not derived from an expression, a parameter, a column reference nor a variable.It can be a string or a number.
A string literal is a series of characters enclosed between a pair of apostrophes (“single quotes”).The maximum length of a string literal is 32,765 for CHAR
/VARCHAR
, or 65,533 bytes for BLOB
;the maximum character count will be determined by the number of bytes used to encode each character.
Formally, the syntax of a normal string literal is:
<char-literal> ::= [<introducer> charset-name] <quote> [<char>...] <quote> [{ <separator> <quote> [<char>...] <quote> }... ] <separator> ::= { <comment> | <white space> } <introducer> ::= underscore (U+005F) <quote> ::= apostrophe (U+0027) <char> ::= character representation; apostrophe is escaped by doubling
Note
|
|
The character set of a string constant is assumed to be the same as the character set of its destined storage.
-- Literal containing single quote
select 'O''Reilly' from RDB$DATABASE;
-- output: O'Reilly
-- whitespace between literal
select 'ab'
'cd'
from RDB$DATABASE;
-- output: abcd
-- comment and whitespace between literal
select 'ab' /* comment */ 'cd'
from RDB$DATABASE;
-- output: abcd