4. Embedded SQL for Fortran : Fortran Variables and Data Types : Variable and Type Declarations : Embedded SQL/Fortran Declarations Example
 
Share this page                  
Embedded SQL/Fortran Declarations Example
The following example demonstrates some simple Embedded SQL/Fortran declarations:
C Include error handling 
            exec sql include sqlca
            exec sql begin declare section

C Variables of each data type 
                byte              dbyte
                logical*1         dlog1
                logical*2         dlog2
                logical*4         dlog4 
                logical           dlog 
                integer*2         dint2 
                integer*4         dint4 
                integer           dint 
                real*4            dreal4 
                real*8            dreal8 
                real              dreal 
                double precision  ddoub
                parameter (max = 1000)

                character*12 dbname 
                character*12 fname, tname, cname

C Structure with a union
                structure /person/
                     byte      age
                     integer   flags
                     union
                         map
                        character*30  fullnm
                         end map
                         map
                        character*12  first
                        character*18  last
                         end map
                      end union
             end structure

             record /person/ person, ptable(MAX)

C From DCLGEN 
             exec sql include 'employee.dcl'

C Compiled forms
             integer  empfrm, dptfrm
        exec sql end declare section
             external  empfrm, dptfrm