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/C.
Example: Declaring a handler
exec sql include sqlca;
main()
{
int error_func();
exec sql connect dbname;
exec sql set_sql (errorhandler = error_func);
. .
}
int
error_func()
{
exec sql begin declare section;
int errnum;
exec sql end declare section;
exec sql inquire_sql (:errnum = ERRORNO);
printf ("Error number is %d", errnum);
return 0;
}
If you are using ANSI C function prototypes, declare the handler function prototype as follows:
int error_funct(void);
where the handler is defined as follows:
int error_funct(void)
{
...
}