Try OpenEdge Now
skip to main content
ABL Database Triggers and Indexes
Database Index Usage : Using the ABL ASSIGN statement
 

Using the ABL ASSIGN statement

When you want to make changes to several indexed components in an ABL procedure, use the ASSIGN statement to define these new values. This method allows you to change several values with minimum I/O processing. Otherwise, the AVM re-indexes records at the end of each statement that changes the value of an index component.
The following code demonstrates how you can change two index values with the ASSIGN statement:

r-sgn2.p

DEFINE VARIABLE neword LIKE order-line.order-num
LABEL "New Order".
DEFINE VARIABLE newordli LIKE order-line.line-num
LABEL "New Order Line".
REPEAT:
PROMPT-FOR order-line.order-num line-num.
FIND order-line USING order-line.order-num AND line-num.
SET neword newordli.
FIND order WHERE order.order-num = neword.
ASSIGN order-line.order-num = neword
order-line.line-num = newordli.
END.
This procedure changes the order number and line number of an order-line record. (It copies an order-line from one order to another.) It sets the new values into variables and modifies the record with a single ASSIGN statement that contains two assignment phrases in the form field=expression. So both fields are changed within a single statement. Because order-num and line-num are used jointly in one index, this method avoids having the indexing done until both values change.