Example 2: CONSTRUCT with binding by field name

Form definition file "form1.per" (same as in Example 1)

Program:
SCHEMA office
MAIN
  DEFINE condition STRING
  DEFINE statement STRING
  DEFINE cust RECORD LIKE customer.*
    
  DATABASE office
  
  OPEN FORM f1 FROM "form1"
  DISPLAY FORM f1
    
  CONSTRUCT BY NAME condition ON customer.* 
    BEFORE CONSTRUCT
      DISPLAY "A*" TO fname 
      DISPLAY "B*" TO lname 
  END CONSTRUCT
    
  LET statement = 
    "SELECT fname, lname FROM customer WHERE " || condition 
  DISPLAY "SQL: " || statement 
    
  DECLARE c1 CURSOR FROM statement
  FOREACH c1 INTO cust.*
    DISPLAY cust.*
  END FOREACH

END MAIN