4. Embedded SQL for Fortran : Fortran Variables and Data Types : Variable and Type Declarations : Structure and Record Declarations Syntax
 
Share this page                  
Structure and Record Declarations Syntax
The Embedded SQL preprocessor supports the declaration and use of user-defined structure variables. In UNIX, the structure variables are an extension to the F77 standard and may not be available on all Fortran compilers.
The syntax of a structure definition is:
structure [/structdef_name/] [field_namelist]
field_declaration
          {field_declaration}
end structure
Note:   
The structdef_name is optional only for a nested structure definition.
The field_namelist is allowed only with a nested structure definition. Each name in the field_namelist constitutes a field in the enclosing structure.
The field_declaration can be a typed data declaration, a nested structure declaration, a union declaration, a record declaration, or a fill item.
The syntax of a union declaration is:
union
              map_declaration
              map_declaration
             {map_declaration}
end union
where map_declaration is:
map
              field_declaration
              {field_declaration}
end map
To use a structure with Embedded SQL statements, you must both define the structure and declare the structure's record in the Embedded SQL declaration section of your program. The syntax of the record declaration is:
record /structdef_name/ structurename {,[/structdef_name/]
                                                structurename}
Note:  The structdef_name must have been previously defined in a structure statement.
For information on the use of structure variables in Embedded SQL statements, see Structure Variables in this chapter.
The following example includes a structure definition and a record declaration:
structure /name_map/
        union
            map
                character*30 fullname
            end map
            map
                character*10 firstnm
                character*2  init
                character*18 lastnm
            end map
        end union
end structure

record /name_map/ empname
The next example shows the definition of a structure containing an array of nested structures:
structure /class_struct/
           character*10   subject
           integer*2      year
           structure      student(100)
C No structure definition name needed
                   character*12 name
                   byte       grade
         end structure
end structure

record /class_struct/ classrec