The EGL embed keyword allows you to include the fields of one structured record in a second structured record without creating a substructure. An SQL record that is an I/O object for relational database access must have such a flat structure.
The only reason to use the embed keyword in place of a structure field name is to avoid adding a level of hierarchy. A structure field identified by the embed keyword cannot specify an array or include a primitive-type specification.
Record address type basicRecord 10 streetAddress1 CHAR(30); 10 streetAddress2 CHAR(30); 10 city CHAR(20); end Record record1 type serialRecord { fileName = "myFile" } 10 person CHAR(30); 10 embed address; end
Record record1 type serialRecord { fileName = "myFile" } 10 person CHAR(30); 10 streetAddress1 CHAR(30); 10 streetAddress2 CHAR(30); 10 city CHAR(20); end
Record common type serialRecord { fileName = "mySerialFile" } 10 a BIN(10); 10 b CHAR(10); end Record recordA type indexedRecord { fileName = "myFile", keyItem = "a" } embed common; // accepts the structure of common, // not the properties end Record recordB type relativeRecord { fileName = "myOtherFile", keyItem = "a" } embed common; end
Record recordA type indexedRecord { fileName = "myFile", keyItem = "a" } 10 a BIN(10); 10 b CHAR(10); end Record recordB type relativeRecord { fileName = "myOtherFile", keyItem = "a" } 10 a BIN(10); 10 b CHAR(10); end