Previous Topic: LEFT-JUSTIFYNext Topic: LOGARITHM


LIKE

Purpose

Returns TRUE or FALSE when comparing a source string value with a supplied string.

Syntax

►►─── LIKE ( string, search-string ──┬──────────────────────┬─ ) ─────────────►◄
                                     └─ ,escape-character ──┘

Parameters

string

Specifies the source string value being tested.

String can be:

search-string

Specifies the string used for testing string.

Search-string can be:

Search-string is compared with string, one character at a time, starting with the leftmost character in each string.

All characters in the search string, except the mask characters listed below, must match the contents of string exactly. The mask characters are:

escape-character

Specifies a 1-character escape character that allows the current LIKE expression to search for the underscore, percent sign, and the escape character itself as an actual character.

Escape-character can be:

Example 1: Testing for an embedded string

In the following example, the string contained in the field ADDRESS is evaluated for an occurrence of BOSTON within the string:

IF LIKE (ADDRESS,'%BOSTON%')
  THEN
    DISPLAY.

Example 2: Testing for an embedded 4-character string starting with 'C'

In the following example, the string contained in the field PNAME is evaluated for an occurrence of a 4-character string starting with 'C':

IF LIKE (PNAME,'%C___')
  THEN
    DISPLAY.

Example 3: Examples using an escape character