Records

A record is a set of data elements called fields. A record field is a variable definition within a Record part. The variable can be based on any of the following types:

A record is typically associated with an external data store like a record in a file or a row in a relational database table or view. EGL makes this association through the concept of the record stereotype and related properties (see Stereotypes). When the record ties to an external data store, the fields in the record must correspond to the data elements in the external data store. For SQL (relational database records) the fields correspond to columns in the database table.

The following example shows an EGL Record that has been specialized for an SQL database:
Record CustomerRecord type SQLRecord
	customerNumber INT;            //key field
	customerName CHAR(25);
	customerAddr1 CHAR(25);
	customerAddr2 CHAR(25);
	customerAddr3 CHAR(25);
	customerBalance MONEY;
end
This Record is only a model. Before you can use it to hold information from a database, you must declare a variable based on this part:
myCustomer CustomerRecord;

Now you have a space to put the data, but still no data. If the Record part is like a blueprint for a bookcase, you now have a real bookcase with nothing on the shelves. The myCustomer variable has an empty shelf for each of the fields in the Record prototype. You fill those shelves with the get statement.

EGL statements use dot syntax to refer to fields within a record, as in the following example:
myCustomer.customerBalance = 0;

In addition to defining records that match the information in a relational database table, you can define records for serial, indexed, or relative files. You can also define records to hold information you need while your program is running, such as counters, totals, and so on.

EGL includes two special types of records with unique characteristics:

Feedback