2 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
4 <!ENTITY % myents SYSTEM "entities.inc">
8 <reference id="ref-connect">
9 <title>Connection and Initialisation</title>
12 This section describes the &clsql; interface for initialising
13 database interfaces of different types, creating and destroying
14 databases and connecting and disconnecting from databases.
18 <!-- Connection and Initialisation -->
20 <refentry id="database">
22 <refentrytitle>DATABASE</refentrytitle>
25 <refname><emphasis>Class</emphasis> <emphasis role="bold">DATABASE</emphasis></refname>
26 <refpurpose>The super-type of all &clsql; databases</refpurpose>
27 <refclass>Class</refclass>
30 <title>Class Precedence List</title>
32 <simplelist type="inline">
33 <member><type>database</type></member>
34 <member><type>standard-object</type></member>
35 <member><type>t</type></member>
40 <title>Description</title> <para>This class is the superclass of
41 all &clsql; databases. The different database back-ends derive
42 subclasses of this class to implement their databases. No
43 instances of this class are ever created by &clsql;.</para>
47 <title class="contenttitle">Class details</title>
48 <programlisting>(defclass DATABASE ()(...))</programlisting>
51 <title class="contenttitle">Slots</title>
54 <property>slot COMMAND-RECORDING-STREAM is of type T</property>
55 <property>slot CONN-POOL is of type T</property>
56 <property>slot NAME is of type T</property>
57 <property>slot RECORD-CACHES is of type T</property>
58 <property>slot RESULT-RECORDING-STREAM is of type T</property>
59 <property>slot STATE is of type T</property>
60 <property>slot TRANSACTION is of type T</property>
61 <property>slot TRANSACTION-LEVEL is of type T</property>
62 <property>slot VIEW-CLASSES is of type T</property>
69 <refentry id="connect-if-exists">
71 <refentrytitle>*CONNECT-IF-EXISTS*</refentrytitle>
74 <refname><emphasis>Variable</emphasis> <emphasis role="bold">*CONNECT-IF-EXISTS*</emphasis></refname>
75 <refpurpose>Default value for the
76 <parameter>if-exists</parameter> parameter of <link
77 linkend="connect"><function>connect</function></link>.</refpurpose>
78 <refclass>Variable</refclass>
81 <title>Value Type</title>
82 <para>A valid argument to the <parameter>if-exists</parameter>
83 parameter of <function>connect</function>, i.e. one of
84 <simplelist type="inline">
85 <member><symbol>:new</symbol></member>
86 <member><symbol>:warn-new</symbol></member>
87 <member><symbol>:error</symbol></member>
88 <member><symbol>:warn-old</symbol></member>
89 <member><symbol>:old</symbol></member>
94 <title>Initial Value</title>
95 <para><symbol>:error</symbol></para>
98 <title>Description</title>
99 <para>The value of this variable is used in calls to
100 <function>connect</function> as the default
101 value of the <parameter>if-exists</parameter>
103 linkend="connect"><function>connect</function></link> for
104 the semantics of the valid values for this variable.</para>
107 <title>Examples</title>
111 <title>Affected By</title>
115 <title>See Also</title>
119 linkend="connect"><function>connect</function></link></member>
129 <refentry id="default-database">
131 <refentrytitle>*DEFAULT-DATABASE*</refentrytitle>
134 <refname><emphasis>Variable</emphasis> <emphasis role="bold">*DEFAULT-DATABASE*</emphasis></refname>
135 <refpurpose>The default database object to use.</refpurpose>
136 <refclass>Variable</refclass>
139 <title>Value Type</title>
140 <para>Any object of type <type>database</type>, or nil to
141 indicate no default database.</para>
144 <title>Initial Value</title>
145 <para><symbol>nil</symbol></para>
148 <title>Description</title>
149 <para>Any function or macro in &clsql; that operates on a
150 database uses the value of this variable as the default value
151 for it's <parameter>database</parameter> parameter.</para>
152 <para>The value of this parameter is changed by calls to
153 <function>connect</function>, which sets
154 <symbol>*default-database*</symbol> to the database object
155 it returns. It is also changed by calls to
156 <function>disconnect</function>, when the database object
157 being disconnected is the same as the value of
158 <symbol>*default-database*</symbol>. In this case
159 <function>disconnect</function> sets
160 <symbol>*default-database*</symbol> to the first database
161 that remains in the list of active databases as returned by
162 <function>connected-databases</function>, or
163 <symbol>nil</symbol> if no further active databases
165 <para>The user may change <symbol>*default-database*</symbol>
166 at any time to a valid value of his choice.</para>
168 <para>If the value of <symbol>*default-database*</symbol> is
169 <symbol>nil</symbol>, then all calls to &clsql; functions on
170 databases must provide a suitable
171 <parameter>database</parameter> parameter, or an error will be
176 <title>Examples</title>
178 (connected-databases)
180 (connect '("dent" "newesim" "dent" "dent") :database-type :mysql)
181 => #<CLSQL-MYSQL:MYSQL-DATABASE {48385F55}>
182 (connect '(nil "template1" "dent" nil) :database-type :postgresql)
183 => #<CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {483868FD}>
184 (connect '("dent" "newesim" "dent" "dent") :database-type :mysql :if-exists :new)
185 => #<CLSQL-MYSQL:MYSQL-DATABASE {48387265}>
187 => #<CLSQL-MYSQL:MYSQL-DATABASE {48387265}>
191 => #<CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {483868FD}>
195 => #<CLSQL-MYSQL:MYSQL-DATABASE {48385F55}>
200 (connected-databases)
205 <title>Affected By</title>
207 <member><link linkend="connect"><function>connect</function></link></member>
208 <member><link linkend="disconnect"><function>disconnect</function></link></member>
212 <title>See Also</title>
215 <member><link linkend="connected-databases"><function>connected-databases</function></link></member>
222 <para>This variable is intended to facilitate working with
223 &clsql; in an interactive
224 fashion at the top-level loop, and because of this,
225 <function>connect</function> and
226 <function>disconnect</function> provide some fairly
227 complex behaviour to keep
228 <symbol>*default-database*</symbol> set to useful values.
229 Programmatic use of &clsql;
230 should never depend on the value of
231 <symbol>*default-database*</symbol> and should provide
232 correct database objects via the
233 <parameter>database</parameter> parameter to functions
239 <refentry id="default-database-type">
241 <refentrytitle>*DEFAULT-DATABASE-TYPE*</refentrytitle>
244 <refname><emphasis>Variable</emphasis> <emphasis role="bold">*DEFAULT-DATABASE-TYPE*</emphasis></refname>
245 <refpurpose>The default database type to use</refpurpose>
246 <refclass>Variable</refclass>
249 <title>Value Type</title>
250 <para>Any keyword representing a valid database back-end of
251 &clsql;, or <symbol>nil</symbol>.</para>
254 <title>Initial Value</title>
255 <para><symbol>nil</symbol></para>
258 <title>Description</title>
259 <para>The value of this variable is used in calls to
260 <function>initialize-database-type</function> and
261 <function>connect</function> as the default value of the
262 <parameter>database-type</parameter> parameter.</para>
264 <para>If the value of this variable is <symbol>nil</symbol>,
266 <function>initialize-database-type</function> or
267 <function>connect</function> will have to specify the
268 <parameter>database-type</parameter> to use, or a
269 general-purpose error will be signalled.</para>
273 <title>Examples</title>
275 (setf *default-database-type* :mysql)
277 (initialize-database-type)
282 <title>Affected By</title>
286 <title>See Also</title>
289 linkend="initialize-database-type"><function>intitialize-database-type</function></link></member>
298 <refentry id="initialized-database-types">
300 <refentrytitle>*INITIALIZED-DATABASE-TYPES*</refentrytitle>
303 <refname><emphasis>Variable</emphasis> <emphasis role="bold">*INITIALIZED-DATABASE-TYPES*</emphasis></refname>
304 <refpurpose>List of all initialized database types</refpurpose>
305 <refclass>Variable</refclass>
308 <title>Value Type</title>
309 <para>A list of all initialized database types, each of which
310 represented by it's corresponding keyword.</para>
313 <title>Initial Value</title>
314 <para><symbol>nil</symbol></para>
317 <title>Description</title>
318 <para>This variable is updated whenever
319 <function>initialize-database-type</function> is called for a
320 database type which hasn't already been initialized before, as
321 determined by this variable. In that case the keyword
322 representing the database type is pushed onto the list stored in
323 <symbol>*INITIALIZED-DATABASE-TYPES*</symbol>.</para>
325 <para>Attempts to modify the value of this variable will
326 result in undefined behaviour.</para>
330 <title>Examples</title>
332 (setf *default-database-type* :mysql)
334 (initialize-database-type)
336 *initialized-database-types*
341 <title>Affected By</title>
344 <member><function>initialize-database-type</function></member>
349 <title>See Also</title>
352 linkend="initialize-database-type"><function>intitialize-database-type</function></link></member>
357 <para>Direct access to this variable is primarily provided
358 because of compatibility with Harlequin's <application>Common
359 SQL</application>.</para>
363 <refentry id="connect">
365 <refentrytitle>CONNECT</refentrytitle>
368 <refname><emphasis>Function</emphasis> <emphasis role="bold">CONNECT</emphasis></refname>
369 <refpurpose>create a connection to a database.</refpurpose>
370 <refclass>Function</refclass>
373 <title>Syntax</title>
374 <title>Syntax</title>
375 <synopsis><function>connect</function> <replaceable>connection-spec</replaceable> &key <replaceable>if-exists</replaceable> <replaceable>database-type</replaceable> <replaceable>pool</replaceable> <replaceable>make-default</replaceable> => <returnvalue>database</returnvalue></synopsis>
378 <title>Arguments and Values</title>
381 <term><parameter>connection-spec</parameter></term>
383 <para>A vendor specific connection specification supplied
384 as a list or as a string.</para>
388 <term><parameter>if-exists</parameter></term>
390 <para>This indicates the action to take if a connection
391 to the same database exists already. See below for the
392 legal values and actions. It defaults to the value of
393 <symbol>*connect-if-exists*</symbol>.</para>
397 <term><parameter>database-type</parameter></term>
399 <para>A database type specifier, i.e. a keyword.
400 This defaults to the value of
401 <symbol>*default-database-type*</symbol></para>
405 <term><parameter>pool</parameter></term>
407 <para>A boolean flag. If &t;, acquire connection from a
408 pool of open connections. If the pool is empty, a new
409 connection is created. The default is &nil;. This is a
415 <term><parameter>make-default</parameter></term>
417 <para>A boolean flag. If &t;,
418 <symbol>*default-database*</symbol> is set to the new
419 connection, otherwise <symbol>*default-database*</symbol>
420 is not changed. The default is &t;. This is a &clsql;
426 <term><returnvalue>database</returnvalue></term>
428 <para>The database object representing the connection.</para>
434 <title>Description</title>
435 <para>This function takes a connection specification and
436 a database type and creates a connection to the database
437 specified by those. The type and structure of the
438 connection specification depend on the database type.</para>
439 <para>The parameter <parameter>if-exists</parameter> specifies
440 what to do if a connection to the database specified exists
441 already, which is checked by calling
442 <function>find-database</function> on the database name
443 returned by <function>database-name-from-spec</function>
444 when called with the <parameter>connection-spec</parameter>
445 and <parameter>database-type</parameter> parameters. The
446 possible values of <parameter>if-exists</parameter> are:
449 <term><symbol>:new</symbol></term>
451 <para>Go ahead and create a new connection.</para>
455 <term><symbol>:warn-new</symbol></term>
457 <para>This is just like <symbol>:new</symbol>, but
458 also signals a warning of type
459 <errortype>clsql-exists-warning</errortype>,
460 indicating the old and newly created
465 <term><symbol>:error</symbol></term>
467 <para>This will cause <function>connect</function> to
468 signal a correctable error of type
469 <errortype>clsql-exists-error</errortype>. The
470 user may choose to proceed, either by indicating
471 that a new connection shall be created, via the
472 restart <symbol>create-new</symbol>, or by
473 indicating that the existing connection shall be
474 used, via the restart
475 <symbol>use-old</symbol>.</para>
479 <term><symbol>:old</symbol></term>
481 <para>This will cause <function>connect</function> to
482 use an old connection if one exists.</para>
486 <term><symbol>:warn-old</symbol></term>
488 <para>This is just like <symbol>:old</symbol>, but
489 also signals a warning of type
490 <errortype>clsql-exists-warning</errortype>,
491 indicating the old database used, via the slots
492 <symbol>old-db</symbol> and
493 <symbol>new-db</symbol></para>
498 <para>The database name of the returned database object will
499 be the same under <function>string=</function> as that which
500 would be returned by a call to
501 <function>database-name-from-spec</function> with the given
502 <parameter>connection-spec</parameter> and
503 <parameter>database-type</parameter> parameters.</para>
506 <title>Examples</title>
508 (database-name-from-spec '("dent" "newesim" "dent" "dent") :mysql)
509 => "dent/newesim/dent"
510 (connect '("dent" "newesim" "dent" "dent") :database-type :mysql)
511 => #<CLSQL-MYSQL:MYSQL-DATABASE {48036F6D}>
513 => "dent/newesim/dent"
515 (connect '("dent" "newesim" "dent" "dent") :database-type :mysql)
516 >> In call to CONNECT:
517 >> There is an existing connection #<CLSQL-MYSQL:MYSQL-DATABASE {48036F6D}> to database dent/newesim/dent.
520 >> 0: [CREATE-NEW] Create a new connection.
521 >> 1: [USE-OLD ] Use the existing connection.
522 >> 2: [ABORT ] Return to Top-Level.
524 >> Debug (type H for help)
526 >> (CONNECT ("dent" "newesim" "dent" "dent") :IF-EXISTS NIL :DATABASE-TYPE ...)
528 >> ; File: /prj/CLSQL/sql/sql.cl
529 >> (RESTART-CASE (ERROR 'CLSQL-EXISTS-ERROR :OLD-DB OLD-DB)
530 >> (CREATE-NEW NIL :REPORT "Create a new connection."
532 >> (USE-OLD NIL :REPORT "Use the existing connection."
533 >> (SETQ RESULT OLD-DB)))
535 => #<CLSQL-MYSQL:MYSQL-DATABASE {480451F5}>
539 <title>Side Effects</title>
540 <para>A database connection is established, and the resultant
541 database object is registered, so as to appear in the list
542 returned by <function>connected-databases</function>.
543 <symbol>*default-database*</symbol> may be rebound to the
544 created object.</para>
547 <title>Affected by</title>
550 <member><symbol>*default-database-type*</symbol></member>
551 <member><symbol>*connect-if-exists*</symbol></member>
556 <title>Exceptional Situations</title>
557 <para>If the connection specification is not syntactically or
558 semantically correct for the given database type, an error of
559 type <errortype>sql-user-error</errortype> is
560 signalled. If during the connection attempt an error is
561 detected (e.g. because of permission problems, network trouble
562 or any other cause), an error of type
563 <errortype>sql-database-error</errortype> is signalled.</para>
564 <para>If a connection to the database specified by
565 <parameter>connection-spec</parameter> exists already,
566 conditions are signalled according to the
567 <parameter>if-exists</parameter> parameter, as described
571 <title>See Also</title>
573 <member><link linkend="connected-databases"><function>connected-databases</function></link></member>
574 <member><link linkend="disconnect"><function>disconnect</function></link></member>
575 <member><link linkend="reconnect"><function>reconnect</function></link></member>
576 <member><link linkend="connect-if-exists"><function>*connect-if-exists*</function></link></member>
577 <member><link linkend="find-database"><function>find-database</function></link></member>
578 <member><link linkend="status"><function>status</function></link></member>
587 <refentry id="connected-databases">
589 <refentrytitle>CONNECTED-DATABASES</refentrytitle>
592 <refname><emphasis>Function</emphasis> <emphasis role="bold">CONNECTED-DATABASES</emphasis></refname>
593 <refpurpose>Return the list of active database objects.</refpurpose>
594 <refclass>Function</refclass>
597 <title>Syntax</title>
599 <function>connected-databases</function> => <returnvalue>databases</returnvalue></synopsis>
602 <title>Arguments and Values</title>
605 <term><returnvalue>databases</returnvalue></term>
607 <para>The list of active database objects.</para>
613 <title>Description</title>
614 <para>This function returns the list of active database
615 objects, i.e. all those database objects created by calls to
616 <function>connect</function>, which have not been closed by
617 calling <function>disconnect</function> on them.</para>
619 <para>The consequences of modifying the list returned by
620 <function>connected-databases</function> are
625 <title>Examples</title>
627 (connected-databases)
629 (connect '(nil "template1" "dent" nil) :database-type :postgresql)
630 => #<CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {4830BC65}>
631 (connect '("dent" "newesim" "dent" "dent") :database-type :mysql)
632 => #<CLSQL-MYSQL:MYSQL-DATABASE {4830C5AD}>
633 (connected-databases)
634 => (#<CLSQL-MYSQL:MYSQL-DATABASE {4830C5AD}>
635 #<CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {4830BC65}>)
638 (connected-databases)
639 => (#<CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {4830BC65}>)
642 (connected-databases)
647 <title>Side Effects</title>
651 <title>Affected By</title>
654 <member><function>connect</function></member>
655 <member><function>disconnect</function></member>
660 <title>Exceptional Situations</title>
664 <title>See Also</title>
666 <member><link linkend="disconnect"><function>disconnect</function></link></member>
667 <member><link linkend="connect"><function>connect</function></link></member>
668 <member><link linkend="status"><function>status</function></link></member>
669 <member><link linkend="find-database"><function>find-database</function></link></member>
679 <refentry id="database-name">
681 <refentrytitle>DATABASE-NAME</refentrytitle>
684 <refname><emphasis>Generic Function</emphasis> <emphasis role="bold">DATABASE-NAME</emphasis></refname>
685 <refpurpose>Get the name of a database object</refpurpose>
686 <refclass>Generic Function</refclass>
689 <title>Syntax</title>
690 <synopsis><function>database-name</function> <replaceable>database</replaceable> => <returnvalue>name</returnvalue></synopsis>
693 <title>Arguments and Values</title>
696 <term><parameter>database</parameter></term>
698 <para>A database object, either of type
699 <type>database</type> or of type
700 <type>closed-database</type>.</para>
704 <term><returnvalue>name</returnvalue></term>
706 <para>A string describing the identity of the database
707 to which this database object is connected to.</para>
713 <title>Description</title>
714 <para>This function returns the database name of the given
715 database. The database name is a string which somehow
716 describes the identity of the database to which this
717 database object is or has been connected. The database name
718 of a database object is determined at
719 <function>connect</function> time, when a call to
720 <function>database-name-from-spec</function> derives the
721 database name from the connection specification passed to
722 <function>connect</function> in the
723 <parameter>connection-spec</parameter> parameter.</para>
724 <para>The database name is used via
725 <function>find-database</function> in
726 <function>connect</function> to determine whether database
727 connections to the specified database exist already.</para>
728 <para>Usually the database name string will include
729 indications of the host, database name, user, or port that
730 where used during the connection attempt. The only
731 important thing is that this string shall try to identify
732 the database at the other end of the connection. Connection
733 specifications parts like passwords and credentials shall
734 not be used as part of the database name.</para>
737 <title>Examples</title>
739 (database-name-from-spec '("dent" "newesim" "dent" "dent") :mysql)
740 => "dent/newesim/dent"
741 (connect '("dent" "newesim" "dent" "dent") :database-type :mysql)
742 => #<CLSQL-MYSQL:MYSQL-DATABASE {48391DCD}>
743 (database-name *default-database*)
744 => "dent/newesim/dent"
746 (database-name-from-spec '(nil "template1" "dent" nil) :postgresql)
748 (connect '(nil "template1" "dent" nil) :database-type :postgresql)
749 => #<CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {48392D2D}>
750 (database-name *default-database*)
753 (database-name-from-spec '("www.pmsf.de" "template1" "dent" nil) :postgresql)
754 => "www.pmsf.de/template1/dent"
758 <title>Side Effects</title>
762 <title>Affected By</title>
765 <member><link linkend="database-name-from-spec"><function>database-name-from-spec</function></link></member>
770 <title>Exceptional Situations</title>
771 <para>Will signal an error if the object passed as the
772 <parameter>database</parameter> parameter is neither of type
773 <type>database</type> nor of type
774 <type>closed-database</type>.</para>
777 <title>See Also</title>
781 linkend="connect"><function>connect</function></link></member>
783 linkend="find-database"><function>find-database</function></link></member>
784 <member><link linkend="connected-databases"><function>connected-databases</function></link></member>
785 <member><link linkend="disconnect"><function>disconnect</function></link></member>
786 <member><link linkend="status"><function>status</function></link></member>
796 <refentry id="database-name-from-spec">
798 <refentrytitle>DATABASE-NAME-FROM-SPEC</refentrytitle>
801 <refname><emphasis>Generic Function</emphasis> <emphasis role="bold">DATABASE-NAME-FROM-SPEC</emphasis></refname>
802 <refpurpose>Return the database name string corresponding to
803 the given connection specification.</refpurpose>
804 <refclass>Generic Function</refclass>
807 <title>Syntax</title>
809 <function>database-name-from-spec</function> <replaceable>connection-spec</replaceable> <replaceable>database-type</replaceable> => <returnvalue>name</returnvalue></synopsis>
812 <title>Arguments and Values</title>
815 <term><parameter>connection-spec</parameter></term>
817 <para>A connection specification, whose structure and
818 interpretation are dependent on the
819 <parameter>database-type</parameter>.</para>
823 <term><parameter>database-type</parameter></term>
825 <para>A database type specifier, i.e. a keyword.</para>
829 <term><returnvalue>name</returnvalue></term>
831 <para>A string denoting a database name.</para>
837 <title>Description</title>
838 <para>This generic function takes a connection specification
839 and a database type and returns the database name of the
840 database object that would be created had
841 <function>connect</function> been called with the given
842 connection specification and database types.</para>
843 <para>This function is useful in determining a database name
844 from the connection specification, since the way the
845 connection specification is converted into a database name
846 is dependent on the database type.</para>
849 <title>Examples</title>
851 (database-name-from-spec '("dent" "newesim" "dent" "dent") :mysql)
852 => "dent/newesim/dent"
853 (connect '("dent" "newesim" "dent" "dent") :database-type :mysql)
854 => #<CLSQL-MYSQL:MYSQL-DATABASE {48391DCD}>
855 (database-name *default-database*)
856 => "dent/newesim/dent"
858 (database-name-from-spec '(nil "template1" "dent" nil) :postgresql)
860 (connect '(nil "template1" "dent" nil) :database-type :postgresql)
861 => #<CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {48392D2D}>
862 (database-name *default-database*)
865 (database-name-from-spec '("www.pmsf.de" "template1" "dent" nil) :postgresql)
866 => "www.pmsf.de/template1/dent"
868 (find-database "dent/newesim/dent")
869 => #<CLSQL-MYSQL:MYSQL-DATABASE {484E91C5}>
870 (find-database "/template1/dent")
871 => #<CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {48392D2D}>
872 (find-database "www.pmsf.de/template1/dent" nil)
875 => #<CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {48392D2D}>
879 <title>Side Effects</title>
883 <title>Affected by</title>
887 <title>Exceptional Situations</title>
888 <para>If the value of <parameter>connection-spec</parameter>
889 is not a valid connection specification for the given
890 database type, an error of type
891 <errortype>clsql-invalid-spec-error</errortype> might be
895 <title>See Also</title>
898 <member><link linkend="connect"><function>connect</function></link></member>
904 <para><function>database-name-from-spec</function> is a
905 &clsql; extension.</para>
909 <refentry id="database-type">
911 <refentrytitle>DATABASE-TYPE</refentrytitle>
914 <refname><emphasis>Generic Function</emphasis> <emphasis role="bold">DATABASE-TYPE</emphasis></refname>
915 <refpurpose>Get the type of a database object.</refpurpose>
916 <refclass>Generic Function</refclass>
919 <title>Syntax</title>
921 <function>database-type</function> <replaceable>DATABASE</replaceable> => <returnvalue>type</returnvalue></synopsis>
924 <title>Arguments and Values</title>
927 <term><parameter>database</parameter></term>
929 <para>A database object, either of type
930 <type>database</type> or of type
931 <type>closed-database</type>.</para>
935 <term><returnvalue>type</returnvalue></term>
937 <para>A keyword symbol denoting a known database back-end.</para>
943 <title>Description</title>
945 Returns the type of <parameter>database</parameter>.
949 <title>Examples</title>
951 (connect '(nil "template1" "dent" nil) :database-type :postgresql)
952 => #<CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {48392D2D}>
953 (database-type *default-database*)
958 <title>Side Effects</title>
964 <title>Affected by</title>
970 <title>Exceptional Situations</title>
971 <para>Will signal an error if the object passed as the
972 <parameter>database</parameter> parameter is neither of type
973 <type>database</type> nor of type
974 <type>closed-database</type>.</para>
977 <title>See Also</title>
981 linkend="connect"><function>connect</function></link></member>
983 linkend="find-database"><function>find-database</function></link></member>
984 <member><link linkend="connected-databases"><function>connected-databases</function></link></member>
985 <member><link linkend="disconnect"><function>disconnect</function></link></member>
986 <member><link linkend="status"><function>status</function></link></member>
993 <function>database-type</function> is a &clsql; extension.
998 <refentry id="disconnect">
1000 <refentrytitle>DISCONNECT</refentrytitle>
1003 <refname><emphasis>Function</emphasis> <emphasis role="bold">DISCONNECT</emphasis></refname>
1004 <refpurpose>close a database connection</refpurpose>
1005 <refclass>Function</refclass>
1008 <title>Syntax</title>
1009 <synopsis><function>disconnect</function> &key <replaceable>database</replaceable> <replaceable>error</replaceable> => <returnvalue>result</returnvalue></synopsis>
1012 <title>Arguments and Values</title>
1015 <term><parameter>error</parameter></term>
1017 <para>A boolean flag indicating whether to signal an error
1018 if <parameter>database</parameter> is non-nil but cannot
1024 <term><parameter>database</parameter></term>
1026 <para>The database to disconnect, which defaults to the
1027 database indicated by
1028 <symbol>*default-database*</symbol>.</para>
1032 <term><parameter>result</parameter></term>
1034 <para>A Boolean indicating whether a connection was
1035 successfully disconnected.
1042 <title>Description</title>
1043 <para>This function takes a <type>database</type> object as
1044 returned by <function>connect</function>, and closes the
1045 connection. If no matching database is found and
1046 <parameter>error</parameter> and
1047 <parameter>database</parameter> are both non-nil an error is
1048 signaled, otherwise nil is returned. If the database is from a
1049 pool it will be released to this pool.
1052 <para>The status of the object passed is changed to closed
1053 after the disconnection succeeds, thereby preventing further
1054 use of the object as an argument to &clsql; functions, with
1055 the exception of <function>database-name</function> and
1056 <function>database-type</function>. If the user does pass a
1057 closed database to any other &clsql; function, an error of
1058 type <errortype>sql-fatal-error</errortype> is
1062 <title>Examples</title>
1064 (disconnect :database (find-database "dent/newesim/dent"))
1069 <title>Side Effects</title>
1070 <para>The database connection is closed, and the database
1071 object is removed from the list of connected databases as
1072 returned by <function>connected-databases</function>.</para>
1073 <para>The state of the database object is changed to
1074 <type>closed</type>.</para>
1075 <para>If the database object passed is the same under
1076 <function>eq</function> as the value of
1077 <symbol>*default-database*</symbol>, then
1078 <symbol>*default-database*</symbol> is set to the first
1079 remaining database from
1080 <function>connected-databases</function> or to nil if no
1081 further active database exists.</para>
1084 <title>Affected by</title>
1087 <member><symbol>*default-database*</symbol></member>
1092 <title>Exceptional Situations</title>
1093 <para>If during the disconnection attempt an error is detected
1094 (e.g. because of network trouble or any other cause), an error
1095 of type <errortype>sql-error</errortype> might be
1099 <title>See Also</title>
1102 <member><link linkend="connect"><function>connect</function></link></member>
1103 <member><link linkend="disconnect-pooled"><function>disconnect-pooled</function></link></member>
1108 <title>Notes</title>
1113 <refentry id="disconnect-pooled">
1115 <refentrytitle>DISCONNECT-POOLED</refentrytitle>
1118 <refname><emphasis>Function</emphasis> <emphasis role="bold">DISCONNECT-POOLED</emphasis></refname>
1119 <refpurpose>closes all pooled database connections</refpurpose>
1120 <refclass>Function</refclass>
1123 <title>Syntax</title>
1124 <synopsis><function>disconnect-pooled</function> => <returnvalue>t</returnvalue></synopsis>
1127 <title>Description</title>
1128 <para>This function disconnects all database connections
1129 that have been placed into the pool by calling <link
1130 linkend="connect"><function>connect</function></link> with
1135 <title>Examples</title>
1142 <title>Side Effects</title>
1143 <para>Database connections will be closed and entries in the pool are removed.
1147 <title>Affected by</title>
1150 <member><function>disconnect</function></member>
1155 <title>Exceptional Situations</title>
1156 <para>If during the disconnection attempt an error is
1157 detected (e.g. because of network trouble or any other
1158 cause), an error of type <errortype>clsql-error</errortype>
1159 might be signalled.</para>
1162 <title>See Also</title>
1165 <member><link linkend="connect"><function>connect</function></link></member>
1166 <member><link linkend="disconnect"><function>disconnect</function></link></member>
1171 <title>Notes</title>
1172 <para><function>disconnect-pooled</function> is a &clsql;
1177 <refentry id="find-database">
1179 <refentrytitle>FIND-DATABASE</refentrytitle>
1182 <refname><emphasis>Function</emphasis> <emphasis role="bold">FIND-DATABASE</emphasis></refname>
1183 <refpurpose>>Locate a database object through it's
1185 <refclass>Function</refclass>
1188 <title>Syntax</title>
1189 <synopsis><function>find-database</function> <replaceable>database</replaceable> &optional <replaceable>errorp</replaceable> => <returnvalue>result</returnvalue></synopsis>
1192 <title>Arguments and Values</title>
1195 <term><parameter>database</parameter></term>
1197 <para>A database object or a string, denoting a database
1202 <term><parameter>errorp</parameter></term>
1204 <para>A generalized boolean. Defaults to
1205 <symbol>t</symbol>.</para>
1209 <term><parameter>db-type</parameter></term>
1212 A keyword symbol denoting a known database back-end. This
1213 is a &clsql; extension.
1218 <term><returnvalue>result</returnvalue></term>
1220 <para>Either a database object, or, if
1221 <parameter>errorp</parameter> is <symbol>nil</symbol>,
1222 possibly <symbol>nil</symbol>.</para>
1228 <title>Description</title>
1229 <para><function>find-database</function> locates an active
1230 database object given the specification in
1231 <parameter>database</parameter>. If
1232 <parameter>database</parameter> is an object of type
1233 <type>database</type>, <function>find-database</function>
1234 returns this. Otherwise it will search the active databases
1235 as indicated by the list returned by
1236 <function>connected-databases</function> for a database of
1237 type <parameter>db-type</parameter> whose name (as returned by
1238 <function>database-name</function> is equal as per
1239 <function>string=</function> to the string passed as
1240 <parameter>database</parameter>. If it succeeds, it returns
1241 the first database found.</para>
1243 If <parameter>db-type</parameter> is nil all databases
1244 matching the string <parameter>database</parameter> are
1245 considered. If no matching databases are found and
1246 <parameter>errorp</parameter> is nil then nil is
1247 returned. If <parameter>errorp</parameter> is nil and one or
1248 more matching databases are found, then the most recently
1249 connected database is returned as a first value and the
1250 number of matching databases is returned as a second
1251 value. If no, or more than one, matching databases are found
1252 and <parameter>errorp</parameter> is true, an error is
1257 <title>Examples</title>
1259 (database-name-from-spec '("dent" "newesim" "dent" "dent") :mysql)
1260 => "dent/newesim/dent"
1261 (connect '("dent" "newesim" "dent" "dent") :database-type :mysql)
1262 => #<CLSQL-MYSQL:MYSQL-DATABASE {48391DCD}>
1263 (database-name *default-database*)
1264 => "dent/newesim/dent"
1266 (database-name-from-spec '(nil "template1" "dent" nil) :postgresql)
1267 => "/template1/dent"
1268 (connect '(nil "template1" "dent" nil) :database-type :postgresql)
1269 => #<CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {48392D2D}>
1270 (database-name *default-database*)
1271 => "/template1/dent"
1273 (database-name-from-spec '("www.pmsf.de" "template1" "dent" nil) :postgresql)
1274 => "www.pmsf.de/template1/dent"
1276 (find-database "dent/newesim/dent")
1277 => #<CLSQL-MYSQL:MYSQL-DATABASE {484E91C5}>
1278 (find-database "/template1/dent")
1279 => #<CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {48392D2D}>
1280 (find-database "www.pmsf.de/template1/dent" nil)
1283 => #<CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {48392D2D}>
1287 <title>Side Effects</title>
1291 <title>Affected By</title>
1294 <member><link linkend="connected-databases"><function>connected-databases</function></link></member>
1299 <title>Exceptional Situations</title>
1300 <para>Will signal an error of type
1301 <errortype>clsql-error</errortype> if no matching database
1302 can be found, and <parameter>errorp</parameter> is true.
1303 Will signal an error if the value of
1304 <parameter>database</parameter> is neither an object of type
1305 <type>database</type> nor a string.</para>
1308 <title>See Also</title>
1312 linkend="database-name"><function>database-name</function></link></member>
1314 linkend="database-name-from-spec"><function>database-name-from-spec</function></link></member>
1315 <member><link linkend="disconnect"><function>disconnect</function></link></member>
1316 <member><link linkend="connect"><function>connect</function></link></member>
1317 <member><link linkend="status"><function>status</function></link></member>
1318 <member><link linkend="connected-databases"><function>connected-databases</function></link></member>
1323 <title>Notes</title>
1328 <refentry id="initialize-database-type">
1330 <refentrytitle>INITIALIZE-DATABASE-TYPE</refentrytitle>
1333 <refname><emphasis>Function</emphasis> <emphasis role="bold">INITIALIZE-DATABASE-TYPE</emphasis></refname>
1334 <refpurpose>Initializes a database type</refpurpose>
1335 <refclass>Function</refclass>
1338 <title>Syntax</title>
1340 <function>initialize-database-type &key database-type</function> => <returnvalue>result</returnvalue></synopsis>
1343 <title>Arguments and Values</title>
1346 <term><parameter>database-type</parameter></term>
1348 <para>The database type to initialize, i.e. a keyword
1349 symbol denoting a known database back-end. Defaults to
1351 <symbol>*default-database-type*</symbol>.</para>
1355 <term><returnvalue>result</returnvalue></term>
1357 <para>Either <symbol>nil</symbol> if the initialization
1358 attempt fails, or <symbol>t</symbol> otherwise.</para>
1364 <title>Description</title>
1365 <para>If the back-end specified by
1366 <parameter>database-type</parameter> has not already been
1367 initialized, as seen from
1368 <symbol>*initialized-database-types*</symbol>, an attempt is
1369 made to initialize the database. If this attempt succeeds,
1370 or the back-end has already been initialized, the function
1371 returns t, and places the keyword denoting the database type
1372 onto the list stored in
1373 <symbol>*initialized-database-types*</symbol>, if not
1374 already present.</para>
1375 <para>If initialization fails, the function returns
1376 <symbol>nil</symbol>, and/or signals an error of type
1377 <errortype>clsql-error</errortype>. The kind of action
1378 taken depends on the back-end and the cause of the
1382 <title>Examples</title>
1384 *initialized-database-types*
1386 (setf *default-database-type* :mysql)
1388 (initialize-database-type)
1389 >> Compiling LAMBDA (#:G897 #:G898 #:G901 #:G902):
1390 >> Compiling Top-Level Form:
1393 *initialized-database-types*
1395 (initialize-database-type)
1397 *initialized-database-types*
1402 <title>Side Effects</title>
1403 <para>The database back-end corresponding to the database type
1404 specified is initialized, unless it has already been
1405 initialized. This can involve any number of other side
1406 effects, as determined by the back-end implementation (like
1407 e.g. loading of foreign code, calling of foreign code,
1408 networking operations, etc.). If initialization is
1409 attempted and succeeds, the
1410 <parameter>database-type</parameter> is pushed onto the list
1412 <symbol>*initialized-database-types*</symbol>.</para>
1415 <title>Affected by</title>
1418 <member><symbol>*default-database-type*</symbol></member>
1419 <member><symbol>*initialized-database-types*</symbol></member>
1424 <title>Exceptional Situations</title>
1425 <para>If an error is encountered during the initialization
1426 attempt, the back-end may signal errors of kind
1427 <errortype>clsql-error</errortype>.</para>
1430 <title>See Also</title>
1432 <member><link linkend="initialized-database-types"><function>*initialized-database-types*</function></link></member>
1433 <member><link linkend="default-database-type"><function>*default-database-type*</function></link></member>
1437 <title>Notes</title>
1442 <refentry id="reconnect">
1444 <refentrytitle>RECONNECT</refentrytitle>
1447 <refname><emphasis>Function</emphasis> <emphasis role="bold">RECONNECT</emphasis></refname>
1448 <refpurpose>Re-establishes the connection between a database object and its RDBMS.</refpurpose>
1449 <refclass>Function</refclass>
1452 <title>Syntax</title>
1454 <function>reconnect</function> &key <parameter>database</parameter> <parameter>error</parameter> <parameter>force</parameter> => <returnvalue>result</returnvalue></synopsis>
1457 <title>Arguments and Values</title>
1460 <term><parameter>database</parameter></term>
1462 <para>The database to reconnect, which defaults to the
1463 database indicated by
1464 <symbol>*default-database*</symbol>.</para>
1468 <term><parameter>error</parameter></term>
1470 <para>A boolean flag indicating whether to signal an error
1471 if <parameter>database</parameter> is non-nil but cannot
1472 be found. The default value is &nil;.
1477 <term><parameter>force</parameter></term>
1479 <para>A Boolean indicating whether to signal an error if the
1480 database connection has been lost. The default value is &t;.
1485 <term><parameter>result</parameter></term>
1487 <para>A Boolean indicating whether the database was
1488 successfully reconnected.
1495 <title>Description</title>
1496 <para>Reconnects <parameter>database</parameter> which defaults
1497 to <symbol>*default-database*</symbol> to the underlying
1498 database management system. On success, &t; is returned and the
1499 variable <symbol>*default-database*</symbol> is set to the newly
1500 reconnected database. If <parameter>database</parameter> is a
1501 database instance, this object is closed. If
1502 <parameter>database</parameter> is a string, then a connected
1503 database whose name matches <parameter>database</parameter> is
1504 sought in the list of connected databases. If no matching
1505 database is found and <parameter>error</parameter> and
1506 <parameter>database</parameter> are both non-nil an error is
1507 signaled, otherwise nil is returned.</para>
1509 <para> When the current database connection has been lost, if
1510 <parameter>force</parameter> is non-nil as it is by default, the
1511 connection is closed and errors are suppressed. If
1512 <parameter>force</parameter> is nil and the database connection
1513 cannot be closed, an error is signalled.
1517 <title>Examples</title>
1520 => #<CLSQL-SQLITE:SQLITE-DATABASE :memory: OPEN {48CFBEA5}>
1522 => #<CLSQL-SQLITE:SQLITE-DATABASE :memory: OPEN {48D64105}>
1526 <title>Side Effects</title>
1527 <para>A database connection is re-established and
1528 <symbol>*default-database*</symbol> may be rebound to the supplied
1529 database object.</para>
1532 <title>Affected by</title>
1535 <member><symbol>*default-database*</symbol></member>
1540 <title>Exceptional Situations</title>
1542 An error may be signalled if the specified database cannot be
1543 located or if the database cannot be closed.
1547 <title>See Also</title>
1551 linkend="connect"><function>connect</function></link></member>
1553 linkend="disconnect"><function>disconnect</function></link></member>
1555 linkend="disconnect-pooled"><function>disconnect-pooled</function></link></member>
1560 <title>Notes</title>
1567 <refentry id="status">
1569 <refentrytitle>STATUS</refentrytitle>
1572 <refname><emphasis>Function</emphasis> <emphasis role="bold">STATUS</emphasis></refname>
1573 <refpurpose>Print information about connected databases.</refpurpose>
1574 <refclass>Function</refclass>
1577 <title>Syntax</title>
1579 <function>status</function> &optional <parameter>full</parameter> => <returnvalue></returnvalue></synopsis>
1582 <title>Arguments and Values</title>
1585 <term><parameter>full</parameter></term>
1587 <para>A boolean indicating whether to print additional
1588 table information. The default value is &nil;.
1595 <title>Description</title>
1596 <para>Prints information about the currently connected databases
1597 to <symbol>*STANDARD-OUTPUT*</symbol>. The argument
1598 <parameter>full</parameter> is nil by default and a value of t
1599 means that more detailed information about each database is
1604 <title>Examples</title>
1608 CLSQL STATUS: 2004-06-13 15:07:39
1609 --------------------------------------------------------
1610 DATABASE TYPE RECORDING
1611 --------------------------------------------------------
1612 localhost/test/petrov mysql nil
1613 localhost/test/petrov postgresql nil
1614 localhost/test/petrov postgresql-socket nil
1615 mysql-test/petrov odbc nil
1616 * :memory: sqlite nil
1617 --------------------------------------------------------
1621 CLSQL STATUS: 2004-06-13 15:08:08
1622 -------------------------------------------------------------------------------
1623 DATABASE TYPE RECORDING POOLED TABLES VIEWS
1624 -------------------------------------------------------------------------------
1625 localhost/test/petrov mysql nil nil 7 0
1626 localhost/test/petrov postgresql nil nil 7 0
1627 localhost/test/petrov postgresql-socket nil nil 7 0
1628 test/petrov odbc nil nil 7 0
1629 * :memory: sqlite nil nil 0 0
1630 -------------------------------------------------------------------------------
1634 <title>Side Effects</title>
1640 <title>Affected by</title>
1646 <title>Exceptional Situations</title>
1652 <title>See Also</title>
1655 <member><link linkend="connected-databases"><function>connected-databases</function></link></member>
1656 <member><link linkend="connect"><function>connect</function></link></member>
1657 <member><link linkend="disconnect"><function>disconnect</function></link></member>
1658 <member><link linkend="connect-if-exists"><function>*connect-if-exists*</function></link></member>
1659 <member><link linkend="find-database"><function>find-database</function></link></member>
1664 <title>Notes</title>
1672 <!-- create/probe/list/destroytruncate-database -->
1674 <refentry id="create-database">
1676 <refentrytitle>CREATE-DATABASE</refentrytitle>
1679 <refname><emphasis>Function</emphasis> <emphasis role="bold">CREATE-DATABASE</emphasis></refname>
1680 <refpurpose>create a database</refpurpose>
1681 <refclass>Function</refclass>
1684 <title>Syntax</title>
1685 <synopsis><function>create-database</function> <replaceable>connection-spec</replaceable> &key <replaceable>database-type</replaceable> => <returnvalue>success</returnvalue></synopsis>
1688 <title>Arguments and Values</title>
1691 <term><parameter>connection-spec</parameter></term>
1693 <para>A connection specification</para>
1697 <term><parameter>database-type</parameter></term>
1699 <para>A database type specifier, i.e. a keyword.
1700 This defaults to the value of
1701 <symbol>*default-database-type*</symbol></para>
1705 <term><parameter>success</parameter></term>
1707 <para>A boolean flag. If &t;, a new database was
1708 successfully created.
1715 <title>Description</title>
1716 <para>This function creates a database in the database system
1717 specified by <parameter>database-type</parameter>.
1721 <title>Examples</title>
1723 (create-database '("localhost" "new" "dent" "dent") :database-type :mysql)
1726 (create-database '("localhost" "new" "dent" "badpasswd") :database-type :mysql)
1728 Error: While trying to access database localhost/new/dent
1729 using database-type MYSQL:
1730 Error database-create failed: mysqladmin: connect to server at 'localhost' failed
1731 error: 'Access denied for user: 'root@localhost' (Using password: YES)'
1733 [condition type: CLSQL-ACCESS-ERROR]
1737 <title>Side Effects</title>
1738 <para>A database will be created on the filesystem of the host.</para>
1741 <title>Exceptional Situations</title>
1742 <para>An exception will be thrown if the database system does
1743 not allow new databases to be created or if database creation
1747 <title>See Also</title>
1750 <member><link linkend="destroy-database"><function>destroy-database</function></link></member>
1751 <member><link linkend="probe-database"><function>probe-database</function></link></member>
1752 <member><link linkend="list-databases"><function>list-databases</function></link></member>
1757 <title>Notes</title>
1758 <para>This function may invoke the operating systems
1759 functions. Thus, some database systems may require the
1760 administration functions to be available in the current
1761 <symbol>PATH</symbol>. At this time, the
1762 <symbol>:mysql</symbol> backend requires
1763 <filename>mysqladmin</filename> and the
1764 <symbol>:postgresql</symbol> backend requires
1765 <filename>createdb</filename>.</para>
1767 <function>create-database</function> is a &clsql; extension.
1772 <refentry id="destroy-database">
1774 <refentrytitle>DESTROY-DATABASE</refentrytitle>
1777 <refname><emphasis>Function</emphasis> <emphasis role="bold">DESTROY-DATABASE</emphasis></refname>
1778 <refpurpose>destroys a database</refpurpose>
1779 <refclass>Function</refclass>
1782 <title>Syntax</title>
1783 <synopsis><function>destroy-database</function> <replaceable>connection-spec</replaceable> &key <replaceable>database-type</replaceable> => <returnvalue>success</returnvalue></synopsis>
1786 <title>Arguments and Values</title>
1789 <term><parameter>connection-spec</parameter></term>
1791 <para>A connection specification</para>
1795 <term><parameter>database-type</parameter></term>
1797 <para>A database type specifier, i.e. a keyword.
1798 This defaults to the value of
1799 <symbol>*default-database-type*</symbol></para>
1803 <term><parameter>success</parameter></term>
1805 <para>A boolean flag. If &t;, the database was
1806 successfully destroyed.
1813 <title>Description</title>
1814 <para>This function destroys a database in the database system
1815 specified by <parameter>database-type</parameter>.
1819 <title>Examples</title>
1821 (destroy-database '("localhost" "new" "dent" "dent") :database-type :postgresql)
1824 (destroy-database '("localhost" "new" "dent" "dent") :database-type :postgresql)
1826 Error: While trying to access database localhost/test2/root
1827 using database-type POSTGRESQL:
1828 Error database-destory failed: dropdb: database removal failed: ERROR: database "test2" does not exist
1830 [condition type: CLSQL-ACCESS-ERROR]
1834 <title>Side Effects</title>
1835 <para>A database will be removed from the filesystem of the host.</para>
1838 <title>Exceptional Situations</title>
1839 <para>An exception will be thrown if the database system does not
1840 allow databases to be removed, the database does not exist, or
1841 if database removal fails.</para>
1844 <title>See Also</title>
1847 <member><link linkend="create-database"><function>create-database</function></link></member>
1848 <member><link linkend="probe-database"><function>probe-database</function></link></member>
1849 <member><link linkend="list-databases"><function>list-databases</function></link></member>
1854 <title>Notes</title>
1855 <para>This function may invoke the operating systems
1856 functions. Thus, some database systems may require the
1857 administration functions to be available in the current
1858 <symbol>PATH</symbol>. At this time, the
1859 <symbol>:mysql</symbol> backend requires
1860 <filename>mysqladmin</filename> and the
1861 <symbol>:postgresql</symbol> backend requires
1862 <filename>dropdb</filename>.</para>
1864 <function>destroy-database</function> is a &clsql; extension.
1869 <refentry id="probe-database">
1871 <refentrytitle>PROBE-DATABASE</refentrytitle>
1874 <refname><emphasis>Function</emphasis> <emphasis role="bold">PROBE-DATABASE</emphasis></refname>
1875 <refpurpose>tests for existence of a database</refpurpose>
1876 <refclass>Function</refclass>
1879 <title>Syntax</title>
1880 <synopsis><function>probe-database</function> <replaceable>connection-spec</replaceable> &key <replaceable>database-type</replaceable> => <returnvalue>success</returnvalue></synopsis>
1883 <title>Arguments and Values</title>
1886 <term><parameter>connection-spec</parameter></term>
1888 <para>A connection specification</para>
1892 <term><parameter>database-type</parameter></term>
1894 <para>A database type specifier, i.e. a keyword.
1895 This defaults to the value of
1896 <symbol>*default-database-type*</symbol></para>
1900 <term><parameter>success</parameter></term>
1902 <para>A boolean flag. If &t;, the database exists
1903 in the database system.
1910 <title>Description</title>
1911 <para>This function tests for the existence of a database in
1912 the database system specified by
1913 <parameter>database-type</parameter>.
1917 <title>Examples</title>
1919 (probe-database '("localhost" "new" "dent" "dent") :database-type :postgresql)
1924 <title>Side Effects</title>
1928 <title>Exceptional Situations</title>
1929 <para>An exception maybe thrown if the database system does
1930 not receive administrator-level authentication since function
1931 may need to read the administrative database of the database
1935 <title>See Also</title>
1938 <member><link linkend="create-database"><function>create-database</function></link></member>
1939 <member><link linkend="destroy-database"><function>destroy-database</function></link></member>
1940 <member><link linkend="list-databases"><function>list-databases</function></link></member>
1945 <title>Notes</title>
1947 <function>probe-database</function> is a &clsql; extension.
1952 <refentry id="list-databases">
1954 <refentrytitle>LIST-DATABASES</refentrytitle>
1957 <refname><emphasis>Function</emphasis> <emphasis role="bold">LIST-DATABASES</emphasis></refname>
1958 <refpurpose>List databases matching the supplied connection spec
1959 and database type.</refpurpose>
1960 <refclass>Function</refclass>
1963 <title>Syntax</title>
1965 <function>list-databases</function> <parameter>connection-spec</parameter> &key <parameter>database-type</parameter> => <returnvalue>result</returnvalue></synopsis>
1968 <title>Arguments and Values</title>
1971 <term><parameter>connection-spec</parameter></term>
1973 <para>A connection specification</para>
1977 <term><parameter>database-type</parameter></term>
1979 <para>A database type specifier, i.e. a keyword.
1980 This defaults to the value of
1981 <symbol>*default-database-type*</symbol></para>
1985 <term><parameter>result</parameter></term>
1987 <para>A list of matching databases.
1994 <title>Description</title>
1996 This function returns a list of databases existing in the
1997 database system specified by
1998 <parameter>database-type</parameter>.
2002 <title>Examples</title>
2004 (list-databases '("localhost" "new" "dent" "dent") :database-type :postgresql)
2005 => ("address-book" "sql-test" "template1" "template0" "test1" "dent" "test")
2009 <title>Side Effects</title>
2015 <title>Affected by</title>
2021 <title>Exceptional Situations</title>
2023 An exception maybe thrown if the database system does not
2024 receive administrator-level authentication since function may
2025 need to read the administrative database of the database
2030 <title>See Also</title>
2033 <member><link linkend="create-database"><function>create-database</function></link></member>
2034 <member><link linkend="destroy-database"><function>destroy-database</function></link></member>
2035 <member><link linkend="probe-database"><function>probe-database</function></link></member>
2040 <title>Notes</title>
2042 <function>list-databases</function> is a &clsql; extension.
2048 <!-- with-database and with-default-database -->
2050 <refentry id="with-database">
2052 <refentrytitle>WITH-DATABASE</refentrytitle>
2055 <refname><emphasis>Macro</emphasis> <emphasis role="bold">WITH-DATABASE</emphasis></refname>
2056 <refpurpose>Execute a body of code with a variable bound to a
2057 specified database object.</refpurpose>
2058 <refclass>Macro</refclass>
2061 <title>Syntax</title>
2063 <function>with-database</function> <replaceable>db-var</replaceable> <replaceable>connection-spec</replaceable> &rest <replaceable>connect-args</replaceable> &body <replaceable>body</replaceable> => <returnvalue>result</returnvalue></synopsis>
2066 <title>Arguments and Values</title>
2069 <term><parameter>db-var</parameter></term>
2071 <para>A variable to which the specified database is bound.
2076 <term><parameter>connection-spec</parameter></term>
2078 <para>A vendor specific connection specification supplied
2079 as a list or as a string.</para>
2083 <term><parameter>connect-args</parameter></term>
2085 <para>Other optional arguments to <function>connect</function>.
2090 <term><parameter>body</parameter></term>
2092 <para>A Lisp code body.
2097 <term><parameter>result</parameter></term>
2099 <para>Determined by the result of executing the last
2100 expression in <parameter>body</parameter>.
2107 <title>Description</title>
2108 <para>Evaluate <parameter>body</parameter> in an environment,
2109 where <parameter>db-var</parameter> is bound to the database
2110 connection given by <parameter>connection-spec</parameter> and
2111 <parameter>connect-args</parameter>. The connection is
2112 automatically closed or released to the pool on exit from the
2117 <title>Examples</title>
2119 (connected-databases)
2121 (with-database (db '(":memory:") :database-type :sqlite
2125 (connected-databases)
2130 <title>Side Effects</title>
2132 See <function>connect</function> and <function>disconnect</function>.
2136 <title>Affected by</title>
2138 See <function>connect</function> and <function>disconnect</function>.
2142 <title>Exceptional Situations</title>
2144 See <function>connect</function> and <function>disconnect</function>.
2148 <title>See Also</title>
2151 <member><link linkend="connect"><function>connect</function></link></member>
2152 <member><link linkend="disconnect"><function>disconnect</function></link></member>
2153 <member><link linkend="disconnect-pooled"><function>disconnect-pooled</function></link></member>
2154 <member><link linkend="with-default-database"><function>with-default-database</function></link></member>
2159 <title>Notes</title>
2161 <function>with-database</function> is a &clsql; extension.
2166 <refentry id="with-default-database">
2168 <refentrytitle>WITH-DEFAULT-DATABASE</refentrytitle>
2171 <refname><emphasis>Macro</emphasis> <emphasis role="bold">WITH-DEFAULT-DATABASE</emphasis></refname>
2172 <refpurpose>Execute a body of code with <symbol>*default-database*</symbol> bound to a specified database.</refpurpose>
2173 <refclass>Macro</refclass>
2176 <title>Syntax</title>
2178 <function>with-default-database</function> <replaceable>database</replaceable> &rest <replaceable>body</replaceable> => <returnvalue>result</returnvalue></synopsis>
2181 <title>Arguments and Values</title>
2184 <term><parameter>database</parameter></term>
2186 <para>An active database object.
2191 <term><parameter>body</parameter></term>
2193 <para>A Lisp code body.
2198 <term><parameter>result</parameter></term>
2200 <para>Determined by the result of executing the last
2201 expression in <parameter>body</parameter>.
2208 <title>Description</title>
2209 <para>Perform BODY with DATABASE bound as
2214 <title>Examples</title>
2217 => #<CLSQL-ODBC:ODBC-DATABASE new/dent OPEN {49095CAD}>
2219 (let ((database (clsql:find-database ":memory:")))
2220 (with-default-database (database)
2221 (database-name *default-database*)))
2226 <title>Side Effects</title>
2232 <title>Affected by</title>
2238 <title>Exceptional Situations</title>
2240 Calls to &clsql; functions in <parameter>body</parameter> may signal
2241 errors if <parameter>database</parameter> is not an active database
2246 <title>See Also</title>
2249 <member><link linkend="with-database"><function>with-database</function></link></member>
2250 <member><link linkend="default-database"><symbol>*default-database*</symbol></link></member>
2255 <title>Notes</title>
2257 <function>with-default-database</function> is a &clsql; extension.