Assignment (=) statement

Assigns the value of an expression to a database field or variable.

Data movement



Syntax

field = expression [ NO-ERROR ]
field
The name of an ABL data element to which you want to assign the value of expression and that is defined with a data type that is compatible with the data type of expression. This data element can include a:
  • Database or temp-table field
  • Variable scoped to the current procedure, user-defined function, or method of a class or an accessible class-based variable data member, including a subscripted or unsubscripted array variable
  • Parameter defined for the current procedure, user-defined function, or method of a class, including a subscripted or unsubscripted array parameter
  • Writable class-based or COM property, including a subscripted or unsubscripted array property
  • Writable handle attribute (such as PRIVATE-DATA)
  • Writable system handle (such as CURRENT-WINDOW)
  • ABL syntax that specifies a keyword-driven assignment statement (such as the PROPATH statement, SUBSTRING statement, or similar statement)
expression
An expression with a data type that is consistent with the data type of field. For more information, see the Expression reference entry.
NO-ERROR
The NO-ERROR option is used to prevent the statement from raising ERROR and displaying error messages.

For the assignment (=) statement with NO-ERROR, if ERROR is raised, then the leftside of the assignment will be unchanged.

Example

This procedure resets all the monthly quota values to 2500 in all salesrep records. If you want to set values for individual array elements, you can do so by making an explicit assignment using the assignment statement (=) and a specific array reference, such as month-quota[1] or month-quota[i].

r-asgmnt.p

DEFINE VARIABLE ctr AS INTEGER NO-UNDO.

FOR EACH SalesRep:
  DO ctr = 1 TO 12:
    SalesRep.MonthQuota[ctr] = 2500.
  END.
END.

Notes

See also

ASSIGN statement, CAST function, Class-based object reference, COPY-DATASET( ) method, COPY-LOB statement, COPY-TEMP-TABLE( ) method, Data types, Expression, FIX-CODEPAGE statement, NEW statement, NO-ERROR option