replace
The EGL replace statement provides the fundamental "update" capability for the language. The statement writes changed record information back to a file or database. The exact behavior of the statement depends on the way you have stereotyped your record variable (see Stereotypes).
For specific considerations that apply to the replace statement when you use various data source technologies (such as SQL), see the related reference at the end of this topic.
Syntax

- recordVariable
- Contains the new information to be placed in the data source.
- explicitCode
- Explicit code embedded in the replace statement, where your data access technology permits it (as SQL does).
- replaceOptions
- Some data access technologies offer additional options for customizing the replace statement.
- listID
- If you are not working with the default data source that EGL typically associates with this record variable, specify a list ID. This is the character string that you used to identify the list that an EGL open or get statement previously created. You must use a forUpdate option with that open or get statement in order to perform a replace later.
Example
The following example shows how to read and replace a file record:
// ask user for customer # to set key
myCustomer.customerNumber = askCustomerNo();
try
get myCustomer forUpdate;
onException(ex AnyException)
myErrorHandler(ex);
end
myCustomer.customerBalance = newBalance;
try
replace myCustomer;
onException(ex AnyException)
myErrorHandler(ex);
end