4. Embedded SQL for Fortran : Advanced Processing : User-Defined Error, DBevent, and Message Handlers : How to Declare User-Defined Handlers
 
Share this page                  
How to Declare User-Defined Handlers
The following example shows how to declare a handler for use in the set_sql errorhandler statement for ESQL/Fortran:
program TestProg

     exec sql include sqlca

     external error_func
     integer error_func

         exec sql connect dbname
    
     exec sql set_sql (errorhandler = error_func)
     ...
                  program code
     ...
end

integer function error_func

         exec sql include sqlca
    
         exec sql begin declare section
                integer errnum
         exec sql end declare section
         exec sql inquire_sql (:errnum = ERRORNO)
     write (*,60) errnum
60       format ('Errnum is ', I)
end