*DEFAULT-DATABASE* — The default database object to use.Variable
Any function or macro in CLSQL that operates on a
database uses the value of this variable as the default value
for it's database
parameter.
The value of this parameter is changed by calls to
connect
, which sets
*default-database* to the database object
it returns. It is also changed by calls to
disconnect
, when the database object
being disconnected is the same as the value of
*default-database*. In this case
disconnect
sets
*default-database* to the first database
that remains in the list of active databases as returned by
connected-databases
, or
NIL
if no further active databases
exist.
The user may change *default-database* at any time to a valid value of his choice.
If the value of *default-database* is
NIL
, then all calls to CLSQL functions on
databases must provide a suitable
database
parameter, or an error will be
signalled.
(connected-databases) => NIL (connect '("dent" "newesim" "dent" "dent") :database-type :mysql) => #<CLSQL-MYSQL:MYSQL-DATABASE {48385F55}> (connect '(nil "template1" "dent" nil) :database-type :postgresql) => #<CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {483868FD}> (connect '("dent" "newesim" "dent" "dent") :database-type :mysql :if-exists :new) => #<CLSQL-MYSQL:MYSQL-DATABASE {48387265}> *default-database* => #<CLSQL-MYSQL:MYSQL-DATABASE {48387265}> (disconnect) => T *default-database* => #<CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {483868FD}> (disconnect) => T *default-database* => #<CLSQL-MYSQL:MYSQL-DATABASE {48385F55}> (disconnect) => T *default-database* => NIL (connected-databases) => NIL
This variable is intended to facilitate working with
CLSQL in an interactive
fashion at the top-level loop, and because of this,
connect
and
disconnect
provide some fairly
complex behaviour to keep
*default-database* set to useful values.
Programmatic use of CLSQL
should never depend on the value of
*default-database* and should provide
correct database objects via the
database
parameter to functions
called.