7. Embedded SQL for Pascal : 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/Pascal:
program TestProg(input, output);
exec sql include SQLCA;

     function Error_Func: Integer;
     exec sql begin declare section;
     var
     errnum : Integer;
     exec sql end declare section;

     begin
        exec sql inquire_sql (:errnum = ERRORNO);
        write ('Error number is ');
        writeln (errnum);
        Error_Func :=1;     {return value ignored}
     end;

begin
     exec sql connect dbname;
     exec sql set_sql (ERRORHANDLER = Error_Func);
     {                }
     { ESQL will generate            }
     {    IILQshSetHandler ( 1, %immed Error_Func);}
     {                            }
. . .
end.