The zero-length literal and the contains (*CT) function

 

In the Open Query File (OPNQRYF) command, a zero-length literal is denoted as a quoted string with nothing, not even a blank, between the quotation marks (""). Zero-length literal support changes the results of a comparison when used as the compare argument of the contains (*CT) function.

The concept of a zero-length literal was introduced in Version 2, Release 1, Modification 1. Consider this statement:

QRYSLT('field *CT ""')
With zero-length literal support, the statement returns records that contain anything. It is, in essence, a wildcard comparison for any number of characters followed by any number of characters. It is equivalent to:
'field = %WLDCRD("**")'
Before zero-length literal support, (before Version 2, Release 1, Modification 1), the argument ("") was interpreted as a single-byte blank. The statement returned records that contained a single blank somewhere in the field. It was, in essence, a wildcard comparison for any number of characters, followed by a blank, followed by any number of characters. It was equivalent to:
'field = %WLDCRD("* *")'
To get pre-Version 2, Release 1, Modification 1 results with the contains function, code the QRYSLT to explicitly look for the blank:
QRYSLT('field *CT " "')

 

Parent topic:

Using Open Query File (OPNQRYF) command

 

Related concepts


Usage notes for the Open Query File (OPNQRYF) examples