Next: 5.5 Notes on specific
Up: 5. The New XSB-Database
Previous: 5.3.2 Querying Databases
Contents
Index
Each predicate in the XSB-DB interface throws an exception with the functor
xsb_error(database(Number), Message)
where Number is a string with the
error number and Message is a string with a slightly detailed error message.
It is upto the user to catch this exception
and proceed with error handling. This is done by the throw-catch error
handling mechanism in XSB. For example, in order to catch the error which
will be thrown when the user attempts to close a database connection for
a handle (ha) which does not exist:
| ?- catch(db_disconnect(ha),
xsb_error(database(Number), Message), handler(Number, Message)).
It is the user's responsibility to define the handler predicate which can be as simple
as printing out the error number and message or may involve more
complicated processing.
A list of error numbers and messages that are thrown by the XSB-DB interface
is given below:
- XSB_DBI_001: XSB_DBI ERROR: Driver already registered
This error is thrown when the user tries to load a driver, using the load_driver
predicate, which has already been loaded previously.
- XSB_DBI_002: XSB_DBI ERROR: Driver does not exist
This error is thrown when the user tries to connect to a database, using
db_connect, with a driver which has not been loaded.
- XSB_DBI_003: XSB_DBI ERROR: Function does not exist in this driver
This error is thrown when the user tries to use a function support
for which does not exist in the corresponding driver. For example,
this error is generated if the user
tries to use db_prepare for a connection established with the
mysql driver.
- XSB_DBI_004: XSB_DBI ERROR: No such connection handle
This error is thrown when the user tries to use a connection handle
which has not been created.
- XSB_DBI_005: XSB_DBI ERROR: No such query handle
This error is thrown when the user tries to use a query handle which has
not been created.
- XSB_DBI_006: XSB_DBI ERROR: Connection handle already exists
This error is thrown when the user tries to create a connection handle in
db_connect using a name which already exists as a connection handle.
- XSB_DBI_007: XSB_DBI ERROR: Query handle already exists
This error is thrown when the user tries to create a query handle, in
db_query or db_prepare, using a name which already exists as
a query handle for a different query.
- XSB_DBI_008: XSB_DBI ERROR: Not all parameters supplied
This error is thrown when the user tries to execute a prepared statement,
using db_prepare_execute, without supplying values for all the
parameters in the statement.
- XSB_DBI_009: XSB_DBI ERROR: Unbound variable in parameter list
This error is thrown when the user tries to execute a prepared statement,
using db_prepare_execute, without binding all the parameters of the
statement.
Next: 5.5 Notes on specific
Up: 5. The New XSB-Database
Previous: 5.3.2 Querying Databases
Contents
Index
Terrance Swift
2007-10-06