informix
Informix Guide to SQL: Syntax
Segments

Quoted String

A quoted string is a string constant that is surrounded by quotation marks. Use the Quoted String segment whenever you see a reference to a quoted string in a syntax diagram.

Syntax

Element Purpose Restrictions Syntax
character Forms part of the quoted string The character or characters in the quoted string cannot be surrounded by double quotes if the DELIMIDENT environment variable is set. Characters are literal values that you enter from the keyboard.

Usage

You use quoted strings to specify string constants in data manipulation statements and other SQL statements. For example, you can use a quoted string in an INSERT statement to insert a value into a column with a character data type.

Restrictions on Specifying Characters in Quoted Strings

You must observe the following restrictions when you specify character in quoted strings:

Newline Characters in Quoted Strings

By default, the string constant must be written on a single line; that is, you cannot use embedded newline characters in a quoted string. However, you can override this default behavior in one of two ways:

In the following example, the user enables newline characters in quoted strings for a particular session:

If newline characters in quoted strings are not enabled for a session, the following statement is illegal and results in an error:

However, if you enable newline characters in quoted strings for the session, the statement in the preceding example is legal and executes successfully.

For more information on the IFX_ALLOW_NEWLINE function, see IFX_ALLOW_NEWLINE Function. For more information on the ALLOW_NEWLINE parameter in the ONCONFIG file, see your Administrator's Reference.

Using Quotes in Strings

The single quote has no special significance in string constants delimited by double quotes. Likewise, the double quote has no special significance in strings delimited by single quotes. For example, the following strings are valid:

If your string is delimited by double quotes, you can include a double quote in the string by preceding the double quote with another double quote, as shown in the following string:

When the DELIMIDENT environment variable is set, double quotes delimit identifiers, not strings. For more information on delimited identifiers, see Delimited Identifiers.

DATETIME and INTERVAL Values as Strings

You can enter DATETIME and INTERVAL data in the literal forms described in the Literal DATETIME and Literal INTERVAL, or you can enter them as quoted strings. Valid literals that are entered as character strings are converted automatically into DATETIME or INTERVAL values. The following INSERT statements use quoted strings to enter INTERVAL and DATETIME data:

The format of the value in the quoted string must exactly match the format specified by the qualifiers of the column. For the first case in the preceding example, the call_dtime column must be defined with the qualifiers YEAR TO SECOND for the INSERT statement to be valid.

LIKE and MATCHES in a Condition

Quoted strings with the LIKE or MATCHES keyword in a condition can include wildcard characters. For a complete description of how to use wildcard characters, see Condition.

Inserting Values as Quoted Strings

If you are inserting a value that is a quoted string, you must adhere to the following conventions:

Related Information

For a discussion of the DELIMIDENT environment variable, see the Informix Guide to SQL: Reference.

For a discussion of the GLS aspects of quoted strings, see the Informix Guide to GLS Functionality.


Informix Guide to SQL: Syntax, Version 9.2
Copyright © 1999, Informix Software, Inc. All rights reserved