QUOTE_LITERAL scalar function

The QUOTE_LITERAL function returns a string that can be used as a string constant in an SQL statement.

The schema is SYSIBM.

Syntax

Read syntax diagramSkip visual syntax diagram QUOTE_LITERAL ( string-expression )
string-expression

An expression that specifies the input string. The expression must return a character string, signed numeric value, or datetime value. If the data type of the input string is not VARCHAR, it is implicitly cast to VARCHAR before the function is evaluated. If the data type of the input string is CHAR or VARCHAR, the expression must not be FOR BIT DATA (SQLSTATE 42815).

Result

The data type of the result is VARCHAR, and the result has the same codepage and string units as the input string. The length attribute of the result depends on the length attribute of the input string:
Length attribute of the input string Length attribute of the result
L OCTETS min(32672,(L*2)+2) OCTETS
L CODEUNITS32 min(8168,(L*2)+2) CODEUNITS32

If the argument can be null, the result can be null. If the argument is null, the result is the null value.

Examples

Statement Result
quote_literal(42.5) '42.5'
quote_literal('You''re here!') 'You''re here!'