PreviousNextIndex

BEGINS operator

Tests a character expression to see if that expression begins with a second character expression.

Syntax

expression1 BEGINS expression2 

expression1
expression2
Examples

In this procedure, the user supplies a customer name or the first characters of a customer name. The procedure finds customer records where the name field begins with the user’s input. If the customer file is indexed on the name field, this procedure is very efficient and retrieves only the selected records.

r-bgns.p
DEFINE VARIABLE cName NO-UNDO LIKE customer.name LABEL "Name". 
REPEAT: 
  SET cName WITH SIDE-LABELS. 
  FOR EACH Customer NO-LOCK WHERE Customer.Name BEGINS cName: 
    DISPLAY Customer.Name Customer.Address Customer.City Customer.State 
      Customer.PostalCode. 
  END. 
END. 

The next procedure lists exactly the same customers. However, it is much less efficient because it retrieves and examines all customer records, and only displays the ones with the appropriate names.

r-bgns2.p
DEFINE VARIABLE cName NO-UNDO LIKE customer.name LABEL "Name". 
REPEAT: 
  SET cName WITH SIDE-LABELS. 
  /* Create MATCHES pattern */ 
  cName = cName + "*". 
  FOR EACH Customer NO-LOCK WHERE Customer.Name MATCHES cName: 
    DISPLAY Customer.Name Customer.Address Customer.City Customer.State 
      Customer.PostalCode. 
  END. 
END. 

Notes
See also

MATCHES operator


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex