next up previous contents index
Next: 4.2.13 Datalog Up: 4.2 Using the Interface Previous: 4.2.11 Transaction Management   Contents   Index

4.2.12 Interface Flags

Users are given the option to monitor control aspects of the ODBC interface by setting ODBC flags via the predicatesset_odbc_flag/2 and odbc_flag/2.

The first aspect that can be controlled is whether to display SQL statements for SQL queries. This is done by the show_query flag. For example:

| ?- odbc_flag(show_query,Val).

     Val = on
Indicates that SQL statements will now be displayed for all SQL queries, and is the default value for the ODBC interface. To turn it off execute the command set_odbc_flag(show_query,on).

The second aspect that can be controlled is the action taken upon ODBC errors. Three possible actions may be useful in different contexts and with different drivers. First, the error may be ignored, so that a database call succeeds; second the error cause the predicate to fail, and third the error may cause an exception to be thrown to be handled by a catcher (or the default system error handler, see Volume 1).

| ?- odbc_flag(fail_on_error, ignore)
Ignores all ODBC errors, apart from writing a warning. In this case, it's the users' users' responsibility to check each of their actions and do error handling.
| ?- odbc_flag(fail_on_error, fail)
Interface fails whenever error occurs.
| ?- odbc_flag(fail_on_error, throw)
Throws an error-term of the form error(odbc_error,Message,Backtrace), in which Message is a textual description of the ODBC error, and Backtrace is a list of the continuations of the call. These continuations may be printed out by the error handler.
The default value of fail_on_error is on.


next up previous contents index
Next: 4.2.13 Datalog Up: 4.2 Using the Interface Previous: 4.2.11 Transaction Management   Contents   Index
Terrance Swift 2007-10-06