The sqlbreakcallback() function
The sqlbreakcallback() function allows you to specify a timeout interval and to register a callback function. The callback function provides a method for the application to regain control when the database server is processing an SQL request.
Syntax
mint sqlbreakcallback(timeout, callbackfunc_ptr);
int4 timeout;
void (* callbackfunc_ptr)(int status);
- timeout
- The interval of time to wait for an SQL request to execute before
the application process regains control. This value can be as follows:
- -1
- Clears the timeout value.
- 0
- Immediately calls the function that callbackfunc_ptr indicates.
- >0
- Sets the timeout interval to the number of milliseconds to elapse before the application calls the function that callbackfunc_ptr indicates.
The timeout parameter is a 4-byte variable. This parameter is operating-system dependent: it can be a variable with an int, long, or short data type.
- callbackfunc_ptr
- A pointer to the user-defined callback function.
Usage
When callback function is called | Value of status argument |
---|---|
When the database server begins processing an SQL request | status = 1 |
While the database server executes an SQL request, when the timeout interval has elapsed | status = 2 |
When the database server completes the processing of an SQL request | status = 0 |
2
, the callback function can determine whether
the database server can continue processing with one of following
actions: - It can call the sqlbreak() function to cancel the SQL request.
- It can omit the call to sqlbreak() to continue the SQL request.
The callback function, and any of its subroutines, can contain only the following control functions: sqldone(), sqlbreak(), and sqlbreakcallback(). For more information about the callback function, see The timeout interval.
- It disassociates the callback function to discontinue the calling
of the callback function, as follows:
sqlbreakcallback(-1L, (void *)NULL);
- It defines some other callback function or resets the timeout
value to a nonzero value, as follows:
sqlbreakcallback(timeout, callbackfunc_ptr);
For more information about the timeout interval, see The timeout interval.
You must establish a database server connection before you call the sqlbreakcallback() function. The callback function remains in effect for the duration of the connection or until the sqlbreakcallback() function redefines the callback function.
Return codes
- 0
- The call to sqlbreakcallback() was successful.
- <0
- The call to sqlbreakcallback() was not successful.