Name

DISCONNECT — close a database connectionFunction

Syntax

disconnect &key database error => result

Arguments and Values

error

A boolean flag indicating whether to signal an error if database is non-NIL but cannot be found.

database

The database to disconnect, which defaults to the database indicated by *default-database*.

result

A Boolean indicating whether a connection was successfully disconnected.

Description

This function takes a database object as returned by connect, and closes the connection. If no matching database is found and error and database are both non-NIL an error is signaled, otherwise NIL is returned. If the database is from a pool it will be released to this pool.

The status of the object passed is changed to closed after the disconnection succeeds, thereby preventing further use of the object as an argument to CLSQL functions, with the exception of database-name and database-type. If the user does pass a closed database to any other CLSQL function, an error of type sql-fatal-error is signalled.

Examples

(disconnect :database (find-database "dent/newesim/dent"))
=> T
	

Side Effects

The database connection is closed, and the database object is removed from the list of connected databases as returned by connected-databases.

The state of the database object is changed to closed.

If the database object passed is the same under eq as the value of *default-database*, then *default-database* is set to the first remaining database from connected-databases or to NIL if no further active database exists.

Affected by

*default-database*

Exceptional Situations

If during the disconnection attempt an error is detected (e.g. because of network trouble or any other cause), an error of type sql-error might be signalled.

See Also

connect
disconnect-pooled

Notes

None.