Try OpenEdge Now
skip to main content
ABL Reference
ABL Syntax Reference : QUOTER function
 

QUOTER function

Converts the specified data type to CHARACTER and encloses the results in quotes when necessary.
The QUOTER function is intended for use in QUERY-PREPARE where a character predicate must be created from a concatenated list of string variables to form a WHERE clause. In order to process variables, screen values, and input values so that they are suitable for a query WHERE clause, it is often necessary to enclose them in quotes. For example, European-format decimals and character variables must always be enclosed in quotes. You can use the QUOTER function to meet that requirement.

Syntax

QUOTER ( expression [ , quote-char [ , null-string]] )
expression
An expression in the data type that you want to convert to character and enclose with quotes.
quote-char
Either a single or double quote, enclosed in the opposite: "'" or '"'. The default is double quote. Passing ? for this argument results in double quotes.
null-string
The string you want for an unknown value: the word NULL or "" for example. The default is an unquoted question mark, which is the Unknown value (?).
For example, the following code:
DEFINE VARIABLE mychar As CHARACTER NO-UNDO INITIAL "Lift Line Skiing".
...
qhandle:QUERY-PREPARE("FOR EACH Customer WHERE Customer.Name = " +
  QUOTER(mychar))
Would produce this prepare-string:
FOR EACH Customer WHERE Customer.Name = "Lift Line Skiing".

Notes

*To address the situation where an Unknown value (?) in a list of concatenated strings could cause the entire string to be unknown and the QUERY-PREPARE to fail, the QUOTER function does not return the Unknown value (?) if the expression argument is unknown. Instead, it returns a known character value consisting of an UNQUOTED question-mark, by default, or the 3rd argument, if it is present.
*Also, in this situation, a quoted question-mark is not used because it is interpreted as string data in a WHERE clause. After the concatenation is complete, the AVM supplies a normal question mark.
For example, the following code:
DEFINE VARIABLE mychar As CHARACTER NO-UNDO.
...
mychar = ?.
qhandle:QUERY-PREPARE("FOR EACH Customer WHERE Customer.Name = " +
  QUOTER(mychar)).
Would produce this prepare-string:
FOR EACH Customer WHERE Customer.Name = ?.
However, giving the 3rd parameter as "NULL" produces NULL rather than ?.
*For noncharacter data types, if expression is of type DECIMAL, INT64, INTEGER, DATE, DATETIME, DATETIME-TZ, and so on, the following occurs:
*The expression is converted to character and enclosed in quotes. The conversion is similar to the EXPORT format. DATE types, however, always have the 4-digit year.
*Data types with no DISPLAY format like MEMPTR and LVARBINARY return the Unknown value (?).
*If a data type is of type RAW, it is converted to base 64.
For example, the following code:
DEFINE VARIABLE mydec As DECIMAL NO-UNDO INITIAL 12.34.
...
qhandle:QUERY-PREPARE("FOR EACH Customer WHERE Customer.Balance = " +
  QUOTER(mydec)).
Would produce this prepare-string:
FOR EACH Customer WHERE Customer.Balance = "12.34".
This is especially important for European format decimals that look like 12,34 and would not compile in the above statement unless they are enclosed in quotes.
*If expression is of data type CHARACTER, internal quotes are doubled. If the first and last byte are already quotes, then it is assumed that the quoting has already been done, and no further quotes are applied.
*You can use the QUOTER function with an object reference for a class instance to obtain a unique object identifier within the session as a quoted character string.
*When applied to an enum instance, QUOTER will return the enumeration member name as a string. If the enum instance is a flag enum with multiple flags set, the string will be a comma-delimited list of the flags.