4bc296b3fa843278fd26b9d80963f55a4dec18f5
[clsql.git] / doc / ref-connect.xml
1 <?xml version='1.0' ?>
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">
5 %myents;
6 ]>
7
8 <reference id="ref-connect"> 
9   <title>Connection and Initialisation</title> 
10   <partintro>
11     <para> 
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. 
15     </para>
16   </partintro>
17
18   <!-- Connection and Initialisation --> 
19
20   <refentry id="database">
21       <refmeta>
22         <refentrytitle>DATABASE</refentrytitle>
23       </refmeta>
24     <refnamediv>
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>
28     </refnamediv>
29     <refsect1>
30       <title>Class Precedence List</title>
31       <para>
32         <simplelist type="inline">
33           <member><type>database</type></member>
34           <member><type>standard-object</type></member>
35           <member><type>t</type></member>
36         </simplelist>
37       </para>
38     </refsect1>
39     <refsect1>
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>
44     </refsect1>
45     <!-- 
46     <refsect1>
47       <title class="contenttitle">Class details</title>
48       <programlisting>(defclass DATABASE ()(...))</programlisting>
49     </refsect1>
50     <refsect1>
51       <title class="contenttitle">Slots</title>
52       <para>
53         <simplelist> 
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>
63         </simplelist> 
64       </para>
65     </refsect1>
66     --> 
67   </refentry>
68
69   <refentry id="connect-if-exists">
70     <refmeta>
71       <refentrytitle>*CONNECT-IF-EXISTS*</refentrytitle>
72     </refmeta>
73     <refnamediv>
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>
79     </refnamediv>
80     <refsect1>
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>
90         </simplelist>.
91       </para>
92     </refsect1>
93     <refsect1>
94       <title>Initial Value</title>
95       <para><symbol>:error</symbol></para>
96     </refsect1>
97     <refsect1>
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>
102       parameter.  See <link
103       linkend="connect"><function>connect</function></link> for
104       the semantics of the valid values for this variable.</para>
105     </refsect1>
106     <refsect1>
107       <title>Examples</title>
108       <para>None.</para>
109     </refsect1>
110     <refsect1>
111       <title>Affected By</title>
112       <para>None.</para>
113     </refsect1>
114     <refsect1>
115       <title>See Also</title>
116       <para>
117         <simplelist>
118           <member><link
119           linkend="connect"><function>connect</function></link></member>
120         </simplelist>
121       </para>
122     </refsect1>
123     <refsect1>
124       <title>Notes</title>
125       <para>None.</para>
126     </refsect1>
127   </refentry>
128
129   <refentry id="default-database">
130     <refmeta>
131       <refentrytitle>*DEFAULT-DATABASE*</refentrytitle>
132     </refmeta>
133     <refnamediv>
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>
137     </refnamediv>
138     <refsect1>
139       <title>Value Type</title>
140       <para>Any object of type <type>database</type>, or nil to
141       indicate no default database.</para>
142     </refsect1>
143     <refsect1>
144       <title>Initial Value</title>
145       <para><symbol>nil</symbol></para>
146     </refsect1>
147     <refsect1>
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
164       exist.</para>
165       <para>The user may change <symbol>*default-database*</symbol>
166       at any time to a valid value of his choice.</para>
167       <caution>
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
172         signalled.</para>
173       </caution>
174     </refsect1>
175     <refsect1>
176       <title>Examples</title>
177       <screen>
178         (connected-databases)
179         => NIL
180         (connect '("dent" "newesim" "dent" "dent") :database-type :mysql)
181         => #&lt;CLSQL-MYSQL:MYSQL-DATABASE {48385F55}>
182         (connect '(nil "template1" "dent" nil) :database-type :postgresql)
183         => #&lt;CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {483868FD}>
184         (connect '("dent" "newesim" "dent" "dent") :database-type :mysql :if-exists :new)
185         => #&lt;CLSQL-MYSQL:MYSQL-DATABASE {48387265}>
186         *default-database*
187         => #&lt;CLSQL-MYSQL:MYSQL-DATABASE {48387265}>
188         (disconnect)
189         => T
190         *default-database*
191         => #&lt;CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {483868FD}>
192         (disconnect)
193         => T
194         *default-database*
195         => #&lt;CLSQL-MYSQL:MYSQL-DATABASE {48385F55}>
196         (disconnect)
197         => T
198         *default-database*
199         => NIL
200         (connected-databases)
201         => NIL
202       </screen>
203     </refsect1>
204     <refsect1>
205       <title>Affected By</title>
206       <simplelist>
207         <member><link linkend="connect"><function>connect</function></link></member>
208         <member><link linkend="disconnect"><function>disconnect</function></link></member>
209       </simplelist>
210     </refsect1>
211     <refsect1>
212       <title>See Also</title>
213       <para>
214         <simplelist>
215           <member><link linkend="connected-databases"><function>connected-databases</function></link></member>
216         </simplelist>
217       </para>
218     </refsect1>
219     <refsect1>
220       <title>Notes</title>
221       <note>
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
234         called.</para>
235       </note>
236     </refsect1>
237   </refentry>
238
239   <refentry id="default-database-type">
240     <refmeta>
241       <refentrytitle>*DEFAULT-DATABASE-TYPE*</refentrytitle>
242     </refmeta>
243     <refnamediv>
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>
247     </refnamediv>
248     <refsect1>
249       <title>Value Type</title>
250       <para>Any keyword representing a valid database back-end of
251       &clsql;, or <symbol>nil</symbol>.</para>
252     </refsect1>
253     <refsect1>
254       <title>Initial Value</title>
255       <para><symbol>nil</symbol></para>
256     </refsect1>
257     <refsect1>
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>
263       <caution>
264         <para>If the value of this variable is <symbol>nil</symbol>,
265         then all calls to
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>
270       </caution>
271     </refsect1>
272     <refsect1>
273       <title>Examples</title>
274       <screen>
275         (setf *default-database-type* :mysql)
276         => :mysql
277         (initialize-database-type)
278         => t
279       </screen>
280     </refsect1>
281     <refsect1>
282       <title>Affected By</title>
283       <para>None.</para>
284     </refsect1>
285     <refsect1>
286       <title>See Also</title>
287       <simplelist>
288         <member><link
289         linkend="initialize-database-type"><function>intitialize-database-type</function></link></member>
290       </simplelist>
291     </refsect1>
292     <refsect1>
293       <title>Notes</title>
294       <para>None.</para>
295     </refsect1>
296   </refentry>
297
298   <refentry id="initialized-database-types">
299     <refmeta>
300       <refentrytitle>*INITIALIZED-DATABASE-TYPES*</refentrytitle>
301     </refmeta>
302     <refnamediv>
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>
306     </refnamediv>
307     <refsect1>
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>
311     </refsect1>
312     <refsect1>
313       <title>Initial Value</title>
314       <para><symbol>nil</symbol></para>
315     </refsect1>
316     <refsect1>
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>
324       <caution>
325         <para>Attempts to modify the value of this variable will
326         result in undefined behaviour.</para>
327       </caution>
328     </refsect1>
329     <refsect1>
330       <title>Examples</title>
331       <screen>
332         (setf *default-database-type* :mysql)
333         => :mysql
334         (initialize-database-type)
335         => t
336         *initialized-database-types*
337         => (:MYSQL)
338       </screen>
339     </refsect1>
340     <refsect1>
341       <title>Affected By</title>
342       <para>
343         <simplelist>
344           <member><function>initialize-database-type</function></member>
345         </simplelist>
346       </para>
347     </refsect1>
348     <refsect1>
349       <title>See Also</title>
350       <simplelist>
351         <member><link
352         linkend="initialize-database-type"><function>intitialize-database-type</function></link></member>
353       </simplelist>
354     </refsect1>
355     <refsect1>
356       <title>Notes</title>
357       <para>Direct access to this variable is primarily provided
358       because of compatibility with Harlequin's <application>Common
359       SQL</application>.</para>
360     </refsect1>
361   </refentry>
362
363   <refentry id="connect">
364     <refmeta>
365       <refentrytitle>CONNECT</refentrytitle>
366     </refmeta>
367     <refnamediv>
368       <refname><emphasis>Function</emphasis> <emphasis role="bold">CONNECT</emphasis></refname>
369       <refpurpose>create a connection to a database.</refpurpose>
370       <refclass>Function</refclass>
371     </refnamediv>
372     <refsect1>
373       <title>Syntax</title>
374         <title>Syntax</title>
375         <synopsis><function>connect</function> <replaceable>connection-spec</replaceable> &amp;key <replaceable>if-exists</replaceable> <replaceable>database-type</replaceable> <replaceable>pool</replaceable> <replaceable>make-default</replaceable> => <returnvalue>database</returnvalue></synopsis>
376     </refsect1>
377     <refsect1>
378       <title>Arguments and Values</title>
379       <variablelist>
380         <varlistentry>
381           <term><parameter>connection-spec</parameter></term>
382           <listitem>
383             <para>A vendor specific connection specification supplied
384             as a list or as a string.</para>
385           </listitem>
386         </varlistentry>
387         <varlistentry>
388           <term><parameter>if-exists</parameter></term>
389           <listitem>
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>
394           </listitem>
395         </varlistentry>
396         <varlistentry>
397           <term><parameter>database-type</parameter></term>
398           <listitem>
399             <para>A database type specifier, i.e. a keyword.
400             This defaults to the value of
401             <symbol>*default-database-type*</symbol></para>
402           </listitem>
403         </varlistentry>
404         <varlistentry>
405           <term><parameter>pool</parameter></term>
406           <listitem>
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
410             &clsql; extension.
411             </para>
412           </listitem>
413         </varlistentry>
414         <varlistentry>
415           <term><parameter>make-default</parameter></term>
416           <listitem>
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;
421             extension.
422             </para>
423           </listitem>
424         </varlistentry>
425         <varlistentry>
426           <term><returnvalue>database</returnvalue></term>
427           <listitem>
428             <para>The database object representing the connection.</para>
429           </listitem>
430         </varlistentry>
431       </variablelist>
432     </refsect1>
433     <refsect1>
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:
447       <variablelist>
448         <varlistentry>
449           <term><symbol>:new</symbol></term>
450           <listitem>
451             <para>Go ahead and create a new connection.</para>
452           </listitem>
453         </varlistentry>
454         <varlistentry>
455           <term><symbol>:warn-new</symbol></term>
456           <listitem>
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
461             databases.</para>
462           </listitem>
463         </varlistentry>
464         <varlistentry>
465           <term><symbol>:error</symbol></term>
466           <listitem>
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>
476           </listitem>
477         </varlistentry>
478         <varlistentry>
479           <term><symbol>:old</symbol></term>
480           <listitem>
481             <para>This will cause <function>connect</function> to
482             use an old connection if one exists.</para>
483           </listitem>
484         </varlistentry>
485         <varlistentry>
486           <term><symbol>:warn-old</symbol></term>
487           <listitem>
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>
494           </listitem>
495         </varlistentry>
496       </variablelist>
497       </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>
504     </refsect1>
505       <refsect1>
506         <title>Examples</title>
507         <screen>
508 (database-name-from-spec '("dent" "newesim" "dent" "dent") :mysql)
509 => "dent/newesim/dent"
510 (connect '("dent" "newesim" "dent" "dent") :database-type :mysql)
511 => #&lt;CLSQL-MYSQL:MYSQL-DATABASE {48036F6D}>
512 (database-name *)
513 => "dent/newesim/dent"
514
515 (connect '("dent" "newesim" "dent" "dent") :database-type :mysql)
516 >> In call to CONNECT:
517 >>   There is an existing connection #&lt;CLSQL-MYSQL:MYSQL-DATABASE {48036F6D}> to database dent/newesim/dent.
518 >> 
519 >> Restarts:
520 >>   0: [CREATE-NEW] Create a new connection.
521 >>   1: [USE-OLD   ] Use the existing connection.
522 >>   2: [ABORT     ] Return to Top-Level.
523 >> 
524 >> Debug  (type H for help)
525 >> 
526 >> (CONNECT ("dent" "newesim" "dent" "dent") :IF-EXISTS NIL :DATABASE-TYPE ...)
527 >> Source: 
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."
531 >>                (SETQ RESULT #))
532 >>               (USE-OLD NIL :REPORT "Use the existing connection."
533 >>                (SETQ RESULT OLD-DB)))
534 >> 0] 0
535 => #&lt;CLSQL-MYSQL:MYSQL-DATABASE {480451F5}>
536         </screen>
537       </refsect1>
538       <refsect1>
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>
545       </refsect1>
546       <refsect1>
547         <title>Affected by</title>
548         <para>
549         <simplelist>
550           <member><symbol>*default-database-type*</symbol></member>
551           <member><symbol>*connect-if-exists*</symbol></member>
552         </simplelist>
553         </para>
554       </refsect1>
555       <refsect1>
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
568           above.</para>
569       </refsect1>
570       <refsect1>
571         <title>See Also</title>
572         <simplelist>
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>
579         </simplelist>
580       </refsect1>
581       <refsect1>
582         <title>Notes</title>
583         <para>None.</para>
584       </refsect1>
585     </refentry>
586
587   <refentry id="connected-databases">
588     <refmeta>
589       <refentrytitle>CONNECTED-DATABASES</refentrytitle>
590     </refmeta>
591     <refnamediv>
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>
595     </refnamediv>
596     <refsect1>
597       <title>Syntax</title>
598       <synopsis>
599       <function>connected-databases</function> => <returnvalue>databases</returnvalue></synopsis>
600     </refsect1>
601     <refsect1>
602       <title>Arguments and Values</title>
603       <variablelist>
604         <varlistentry>
605           <term><returnvalue>databases</returnvalue></term>
606           <listitem>
607             <para>The list of active database objects.</para>
608           </listitem>
609         </varlistentry>
610       </variablelist>
611     </refsect1>
612     <refsect1>
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> 
618         <caution>
619           <para>The consequences of modifying the list returned by
620             <function>connected-databases</function> are
621             undefined.</para>
622         </caution>
623     </refsect1>
624       <refsect1>
625         <title>Examples</title>
626         <screen>
627 (connected-databases)
628 => NIL
629 (connect '(nil "template1" "dent" nil) :database-type :postgresql)
630 => #&lt;CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {4830BC65}>
631 (connect '("dent" "newesim" "dent" "dent") :database-type :mysql)
632 => #&lt;CLSQL-MYSQL:MYSQL-DATABASE {4830C5AD}>
633 (connected-databases)
634 => (#&lt;CLSQL-MYSQL:MYSQL-DATABASE {4830C5AD}>
635     #&lt;CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {4830BC65}>)
636 (disconnect)
637 => T
638 (connected-databases)
639 => (#&lt;CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {4830BC65}>)
640 (disconnect)
641 => T
642 (connected-databases)
643 => NIL
644         </screen>
645       </refsect1>
646       <refsect1>
647         <title>Side Effects</title>
648         <para>None.</para>
649       </refsect1>
650       <refsect1>
651         <title>Affected By</title>
652         <para>
653         <simplelist>
654           <member><function>connect</function></member>
655           <member><function>disconnect</function></member>
656         </simplelist>
657         </para>
658       </refsect1>
659       <refsect1>
660         <title>Exceptional Situations</title>
661         <para>None.</para>
662       </refsect1>
663       <refsect1>
664         <title>See Also</title>
665         <simplelist>
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>
670           </simplelist>
671       </refsect1>
672       <refsect1>
673         <title>Notes</title>
674         <para>None.</para>
675       </refsect1>
676     </refentry>
677
678
679   <refentry id="database-name">
680     <refmeta>
681       <refentrytitle>DATABASE-NAME</refentrytitle>
682     </refmeta>
683     <refnamediv>
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>
687     </refnamediv>
688     <refsect1>
689       <title>Syntax</title>
690       <synopsis><function>database-name</function> <replaceable>database</replaceable> => <returnvalue>name</returnvalue></synopsis>
691     </refsect1>
692       <refsect1>
693         <title>Arguments and Values</title>
694         <variablelist>
695           <varlistentry>
696             <term><parameter>database</parameter></term>
697             <listitem>
698               <para>A database object, either of type
699                 <type>database</type> or of type
700                 <type>closed-database</type>.</para>
701             </listitem>
702           </varlistentry>
703           <varlistentry>
704             <term><returnvalue>name</returnvalue></term>
705             <listitem>
706               <para>A string describing the identity of the database
707                 to which this database object is connected to.</para>
708             </listitem>
709           </varlistentry>
710         </variablelist>
711       </refsect1>
712       <refsect1>
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>
735       </refsect1>
736       <refsect1>
737         <title>Examples</title>
738         <screen>
739 (database-name-from-spec '("dent" "newesim" "dent" "dent") :mysql)
740 => "dent/newesim/dent"
741 (connect '("dent" "newesim" "dent" "dent") :database-type :mysql)
742 => #&lt;CLSQL-MYSQL:MYSQL-DATABASE {48391DCD}>
743 (database-name *default-database*)
744 => "dent/newesim/dent"
745
746 (database-name-from-spec '(nil "template1" "dent" nil) :postgresql)
747 => "/template1/dent"
748 (connect '(nil "template1" "dent" nil) :database-type :postgresql)
749 => #&lt;CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {48392D2D}>
750 (database-name *default-database*)
751 => "/template1/dent"
752
753 (database-name-from-spec '("www.pmsf.de" "template1" "dent" nil) :postgresql)
754 => "www.pmsf.de/template1/dent"
755         </screen>
756       </refsect1>
757       <refsect1>
758         <title>Side Effects</title>
759         <para>None.</para>
760       </refsect1>
761       <refsect1>
762         <title>Affected By</title>
763         <para>
764         <simplelist>
765           <member><link linkend="database-name-from-spec"><function>database-name-from-spec</function></link></member>
766         </simplelist>
767         </para>
768       </refsect1>
769       <refsect1>
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>
775       </refsect1>
776       <refsect1>
777         <title>See Also</title>
778         <para>
779         <simplelist>
780           <member><link
781           linkend="connect"><function>connect</function></link></member>
782           <member><link
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>
787           </simplelist>
788         </para>
789       </refsect1>
790       <refsect1>
791         <title>Notes</title>
792         <para>None.</para>
793       </refsect1>
794     </refentry>
795
796     <refentry id="database-name-from-spec">
797       <refmeta>
798         <refentrytitle>DATABASE-NAME-FROM-SPEC</refentrytitle>
799       </refmeta>
800       <refnamediv>
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>
805       </refnamediv>
806       <refsect1>
807         <title>Syntax</title>
808         <synopsis>
809           <function>database-name-from-spec</function> <replaceable>connection-spec</replaceable> <replaceable>database-type</replaceable> => <returnvalue>name</returnvalue></synopsis>
810       </refsect1>
811       <refsect1>
812         <title>Arguments and Values</title>
813         <variablelist>
814           <varlistentry>
815             <term><parameter>connection-spec</parameter></term>
816             <listitem>
817               <para>A connection specification, whose structure and
818                 interpretation are dependent on the
819                 <parameter>database-type</parameter>.</para>
820             </listitem>
821           </varlistentry>
822           <varlistentry>
823             <term><parameter>database-type</parameter></term>
824             <listitem>
825               <para>A database type specifier, i.e. a keyword.</para>
826             </listitem>
827           </varlistentry>
828           <varlistentry>
829             <term><returnvalue>name</returnvalue></term>
830             <listitem>
831               <para>A string denoting a database name.</para>
832             </listitem>
833           </varlistentry>
834         </variablelist>
835       </refsect1>
836       <refsect1>
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>
847       </refsect1>
848       <refsect1>
849         <title>Examples</title>
850         <screen>
851 (database-name-from-spec '("dent" "newesim" "dent" "dent") :mysql)
852 => "dent/newesim/dent"
853 (connect '("dent" "newesim" "dent" "dent") :database-type :mysql)
854 => #&lt;CLSQL-MYSQL:MYSQL-DATABASE {48391DCD}>
855 (database-name *default-database*)
856 => "dent/newesim/dent"
857
858 (database-name-from-spec '(nil "template1" "dent" nil) :postgresql)
859 => "/template1/dent"
860 (connect '(nil "template1" "dent" nil) :database-type :postgresql)
861 => #&lt;CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {48392D2D}>
862 (database-name *default-database*)
863 => "/template1/dent"
864
865 (database-name-from-spec '("www.pmsf.de" "template1" "dent" nil) :postgresql)
866 => "www.pmsf.de/template1/dent"
867
868 (find-database "dent/newesim/dent")
869 => #&lt;CLSQL-MYSQL:MYSQL-DATABASE {484E91C5}>
870 (find-database "/template1/dent")
871 => #&lt;CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {48392D2D}>
872 (find-database "www.pmsf.de/template1/dent" nil)
873 => NIL
874 (find-database **)
875 => #&lt;CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {48392D2D}>
876         </screen>
877       </refsect1>
878       <refsect1>
879         <title>Side Effects</title>
880         <para>None.</para>
881       </refsect1>
882       <refsect1>
883         <title>Affected by</title>
884         <para>None.</para>
885       </refsect1>
886       <refsect1>
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
892           signalled.</para>
893       </refsect1>
894       <refsect1>
895         <title>See Also</title>
896         <para>
897         <simplelist>
898           <member><link linkend="connect"><function>connect</function></link></member>
899         </simplelist>
900         </para>
901       </refsect1>
902       <refsect1>
903         <title>Notes</title>
904         <para><function>database-name-from-spec</function> is a
905         &clsql; extension.</para>
906       </refsect1>
907     </refentry>
908
909   <refentry id="database-type">
910     <refmeta>
911       <refentrytitle>DATABASE-TYPE</refentrytitle>
912     </refmeta>
913     <refnamediv>
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>
917     </refnamediv>
918     <refsect1>
919       <title>Syntax</title>
920       <synopsis>
921       <function>database-type</function> <replaceable>DATABASE</replaceable> => <returnvalue>type</returnvalue></synopsis>
922     </refsect1>
923     <refsect1>
924       <title>Arguments and Values</title>
925         <variablelist>
926           <varlistentry>
927             <term><parameter>database</parameter></term>
928             <listitem>
929               <para>A database object, either of type
930               <type>database</type> or of type
931               <type>closed-database</type>.</para>
932             </listitem>
933           </varlistentry>
934           <varlistentry>
935             <term><returnvalue>type</returnvalue></term>
936             <listitem>
937               <para>A keyword symbol denoting a known database back-end.</para>
938             </listitem>
939           </varlistentry>
940       </variablelist>
941     </refsect1>
942     <refsect1>
943       <title>Description</title>
944       <para>
945         Returns the type of <parameter>database</parameter>.
946       </para>
947     </refsect1>
948     <refsect1>
949       <title>Examples</title>
950       <screen>
951 (connect '(nil "template1" "dent" nil) :database-type :postgresql)
952 => #&lt;CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {48392D2D}>
953 (database-type *default-database*)
954 => :postgresql 
955       </screen>
956     </refsect1>
957     <refsect1>
958       <title>Side Effects</title>
959       <para>
960         None. 
961       </para>
962     </refsect1>
963     <refsect1>
964       <title>Affected by</title>
965       <para>
966         None. 
967       </para>
968     </refsect1>
969     <refsect1>
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>
975     </refsect1>
976     <refsect1>
977       <title>See Also</title>
978       <para>
979         <simplelist>
980           <member><link
981           linkend="connect"><function>connect</function></link></member>
982           <member><link
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>
987         </simplelist>
988       </para>
989     </refsect1>
990     <refsect1>
991       <title>Notes</title>
992       <para>
993         <function>database-type</function> is a &clsql; extension. 
994       </para>
995     </refsect1>
996   </refentry>
997
998   <refentry id="disconnect">
999     <refmeta>
1000       <refentrytitle>DISCONNECT</refentrytitle>
1001     </refmeta>
1002     <refnamediv>
1003       <refname><emphasis>Function</emphasis> <emphasis role="bold">DISCONNECT</emphasis></refname>
1004         <refpurpose>close a database connection</refpurpose>
1005         <refclass>Function</refclass>
1006       </refnamediv>
1007       <refsect1>
1008         <title>Syntax</title>
1009         <synopsis><function>disconnect</function> &amp;key <replaceable>database</replaceable> <replaceable>error</replaceable> => <returnvalue>result</returnvalue></synopsis>
1010       </refsect1>
1011       <refsect1>
1012         <title>Arguments and Values</title>
1013         <variablelist>
1014           <varlistentry>
1015             <term><parameter>error</parameter></term>
1016             <listitem>
1017               <para>A boolean flag indicating whether to signal an error 
1018               if <parameter>database</parameter> is non-nil but cannot 
1019               be found. 
1020               </para>
1021             </listitem>
1022           </varlistentry>
1023           <varlistentry>
1024             <term><parameter>database</parameter></term>
1025             <listitem>
1026               <para>The database to disconnect, which defaults to the
1027                 database indicated by
1028                 <symbol>*default-database*</symbol>.</para>
1029             </listitem>
1030           </varlistentry>
1031           <varlistentry>
1032             <term><parameter>result</parameter></term>
1033             <listitem>
1034               <para>A Boolean indicating whether a connection was
1035               successfully disconnected.
1036               </para> 
1037             </listitem>
1038           </varlistentry>
1039         </variablelist>
1040       </refsect1>
1041       <refsect1>
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.
1050         </para> 
1051
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
1059         signalled.</para>
1060       </refsect1>
1061       <refsect1>
1062         <title>Examples</title>
1063         <screen>
1064 (disconnect :database (find-database "dent/newesim/dent"))
1065 => T
1066         </screen>
1067       </refsect1>
1068       <refsect1>
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>
1082       </refsect1>
1083       <refsect1>
1084         <title>Affected by</title>
1085         <para>
1086         <simplelist>
1087           <member><symbol>*default-database*</symbol></member>
1088         </simplelist>
1089         </para>
1090       </refsect1>
1091       <refsect1>
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
1096         signalled.</para>
1097       </refsect1>
1098       <refsect1>
1099         <title>See Also</title>
1100         <para>
1101         <simplelist>
1102           <member><link linkend="connect"><function>connect</function></link></member>
1103           <member><link linkend="disconnect-pooled"><function>disconnect-pooled</function></link></member>
1104         </simplelist>
1105         </para>
1106       </refsect1>
1107       <refsect1>
1108         <title>Notes</title>
1109         <para>None.</para>
1110       </refsect1>
1111     </refentry>
1112
1113     <refentry id="disconnect-pooled">
1114       <refmeta>
1115         <refentrytitle>DISCONNECT-POOLED</refentrytitle>
1116       </refmeta>
1117       <refnamediv>
1118         <refname><emphasis>Function</emphasis> <emphasis role="bold">DISCONNECT-POOLED</emphasis></refname>
1119         <refpurpose>closes all pooled database connections</refpurpose>
1120         <refclass>Function</refclass>
1121       </refnamediv>
1122       <refsect1>
1123         <title>Syntax</title>
1124         <synopsis><function>disconnect-pooled</function> => <returnvalue>t</returnvalue></synopsis>
1125       </refsect1>
1126       <refsect1>
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 
1131           :pool &t;.
1132         </para>
1133       </refsect1>
1134       <refsect1>
1135         <title>Examples</title>
1136         <screen>
1137 (disconnect-pool)
1138 => T
1139         </screen>
1140       </refsect1>
1141       <refsect1>
1142         <title>Side Effects</title>
1143         <para>Database connections will be closed and entries in the pool are removed.
1144         </para>
1145       </refsect1>
1146       <refsect1>
1147         <title>Affected by</title>
1148         <para>
1149         <simplelist>
1150           <member><function>disconnect</function></member>
1151         </simplelist>
1152         </para>
1153       </refsect1>
1154       <refsect1>
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>
1160       </refsect1>
1161       <refsect1>
1162         <title>See Also</title>
1163         <para>
1164         <simplelist>
1165           <member><link linkend="connect"><function>connect</function></link></member>
1166           <member><link linkend="disconnect"><function>disconnect</function></link></member>
1167         </simplelist>
1168         </para>
1169       </refsect1>
1170       <refsect1>
1171         <title>Notes</title>
1172         <para><function>disconnect-pooled</function> is a &clsql;
1173         extension.</para>
1174       </refsect1>
1175     </refentry>
1176
1177   <refentry id="find-database">
1178     <refmeta>
1179       <refentrytitle>FIND-DATABASE</refentrytitle>
1180     </refmeta>
1181     <refnamediv>
1182       <refname><emphasis>Function</emphasis> <emphasis role="bold">FIND-DATABASE</emphasis></refname>
1183       <refpurpose>>Locate a database object through it's
1184       name.</refpurpose>
1185       <refclass>Function</refclass>
1186     </refnamediv>
1187       <refsect1>
1188         <title>Syntax</title>
1189         <synopsis><function>find-database</function> <replaceable>database</replaceable> &amp;optional <replaceable>errorp</replaceable> => <returnvalue>result</returnvalue></synopsis>
1190       </refsect1>
1191       <refsect1>
1192         <title>Arguments and Values</title>
1193         <variablelist>
1194           <varlistentry>
1195             <term><parameter>database</parameter></term>
1196             <listitem>
1197               <para>A database object or a string, denoting a database 
1198                 name.</para>
1199             </listitem>
1200           </varlistentry>
1201           <varlistentry>
1202             <term><parameter>errorp</parameter></term>
1203             <listitem>
1204               <para>A generalized boolean.  Defaults to
1205                 <symbol>t</symbol>.</para>
1206             </listitem>
1207           </varlistentry>
1208           <varlistentry>
1209             <term><parameter>db-type</parameter></term>
1210             <listitem>
1211               <para>
1212                 A keyword symbol denoting a known database back-end. This 
1213                 is a &clsql; extension. 
1214               </para> 
1215             </listitem>
1216           </varlistentry>          
1217           <varlistentry>
1218             <term><returnvalue>result</returnvalue></term>
1219             <listitem>
1220               <para>Either a database object, or, if
1221                 <parameter>errorp</parameter> is <symbol>nil</symbol>, 
1222                 possibly <symbol>nil</symbol>.</para>
1223             </listitem>
1224           </varlistentry>
1225         </variablelist>
1226       </refsect1>
1227       <refsect1>
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>
1242         <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
1253           signalled.
1254         </para> 
1255       </refsect1>
1256       <refsect1>
1257         <title>Examples</title>
1258         <screen>
1259 (database-name-from-spec '("dent" "newesim" "dent" "dent") :mysql)
1260 => "dent/newesim/dent"
1261 (connect '("dent" "newesim" "dent" "dent") :database-type :mysql)
1262 => #&lt;CLSQL-MYSQL:MYSQL-DATABASE {48391DCD}>
1263 (database-name *default-database*)
1264 => "dent/newesim/dent"
1265
1266 (database-name-from-spec '(nil "template1" "dent" nil) :postgresql)
1267 => "/template1/dent"
1268 (connect '(nil "template1" "dent" nil) :database-type :postgresql)
1269 => #&lt;CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {48392D2D}>
1270 (database-name *default-database*)
1271 => "/template1/dent"
1272
1273 (database-name-from-spec '("www.pmsf.de" "template1" "dent" nil) :postgresql)
1274 => "www.pmsf.de/template1/dent"
1275
1276 (find-database "dent/newesim/dent")
1277 => #&lt;CLSQL-MYSQL:MYSQL-DATABASE {484E91C5}>
1278 (find-database "/template1/dent")
1279 => #&lt;CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {48392D2D}>
1280 (find-database "www.pmsf.de/template1/dent" nil)
1281 => NIL
1282 (find-database **)
1283 => #&lt;CLSQL-POSTGRESQL:POSTGRESQL-DATABASE {48392D2D}>
1284         </screen>
1285       </refsect1>
1286       <refsect1>
1287         <title>Side Effects</title>
1288         <para>None.</para>
1289       </refsect1>
1290       <refsect1>
1291         <title>Affected By</title>
1292         <para>
1293         <simplelist>
1294           <member><link linkend="connected-databases"><function>connected-databases</function></link></member>
1295         </simplelist>
1296         </para>
1297       </refsect1>
1298       <refsect1>
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>
1306       </refsect1>
1307       <refsect1>
1308         <title>See Also</title>
1309         <para>
1310         <simplelist>
1311           <member><link
1312           linkend="database-name"><function>database-name</function></link></member>
1313           <member><link
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>
1319         </simplelist>
1320         </para>
1321       </refsect1>
1322       <refsect1>
1323         <title>Notes</title>
1324         <para>None.</para>
1325       </refsect1>
1326     </refentry>
1327
1328   <refentry id="initialize-database-type">
1329     <refmeta>
1330       <refentrytitle>INITIALIZE-DATABASE-TYPE</refentrytitle>
1331     </refmeta>
1332     <refnamediv>
1333       <refname><emphasis>Function</emphasis> <emphasis role="bold">INITIALIZE-DATABASE-TYPE</emphasis></refname>
1334       <refpurpose>Initializes a database type</refpurpose>
1335       <refclass>Function</refclass>
1336     </refnamediv>
1337     <refsect1>
1338       <title>Syntax</title>
1339       <synopsis>
1340       <function>initialize-database-type &amp;key database-type</function> => <returnvalue>result</returnvalue></synopsis>
1341     </refsect1>
1342     <refsect1>
1343       <title>Arguments and Values</title>
1344       <variablelist>
1345         <varlistentry>
1346           <term><parameter>database-type</parameter></term>
1347           <listitem>
1348             <para>The database type to initialize, i.e. a keyword
1349             symbol denoting a known database back-end.  Defaults to
1350             the value of
1351             <symbol>*default-database-type*</symbol>.</para>
1352           </listitem>
1353         </varlistentry>
1354         <varlistentry>
1355           <term><returnvalue>result</returnvalue></term>
1356           <listitem>
1357             <para>Either <symbol>nil</symbol> if the initialization
1358             attempt fails, or <symbol>t</symbol> otherwise.</para>
1359           </listitem>
1360         </varlistentry>
1361       </variablelist>
1362     </refsect1>
1363       <refsect1>
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
1379           problem.</para>
1380       </refsect1>
1381       <refsect1>
1382         <title>Examples</title>
1383         <screen>
1384 *initialized-database-types*
1385 => NIL
1386 (setf *default-database-type* :mysql)
1387 => :MYSQL
1388 (initialize-database-type)
1389 >> Compiling LAMBDA (#:G897 #:G898 #:G901 #:G902): 
1390 >> Compiling Top-Level Form: 
1391 >> 
1392 => T
1393 *initialized-database-types*
1394 => (:MYSQL)
1395 (initialize-database-type)
1396 => T
1397 *initialized-database-types*
1398 => (:MYSQL)
1399         </screen>
1400       </refsect1>
1401       <refsect1>
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 
1411           stored in
1412           <symbol>*initialized-database-types*</symbol>.</para>
1413       </refsect1>
1414       <refsect1>
1415         <title>Affected by</title>
1416         <para>
1417         <simplelist>
1418           <member><symbol>*default-database-type*</symbol></member>
1419           <member><symbol>*initialized-database-types*</symbol></member>
1420         </simplelist>
1421         </para>
1422       </refsect1>
1423       <refsect1>
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>
1428       </refsect1>
1429       <refsect1>
1430         <title>See Also</title>
1431         <simplelist> 
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>
1434         </simplelist> 
1435       </refsect1>
1436       <refsect1>
1437         <title>Notes</title>
1438         <para>None.</para>
1439       </refsect1>
1440     </refentry>
1441
1442   <refentry id="reconnect">
1443     <refmeta>
1444       <refentrytitle>RECONNECT</refentrytitle>
1445     </refmeta>
1446     <refnamediv>
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>
1450     </refnamediv>
1451     <refsect1>
1452       <title>Syntax</title>
1453       <synopsis>
1454       <function>reconnect</function> &amp;key <parameter>database</parameter> <parameter>error</parameter> <parameter>force</parameter> => <returnvalue>result</returnvalue></synopsis>
1455     </refsect1>
1456     <refsect1>
1457       <title>Arguments and Values</title>
1458       <variablelist>
1459         <varlistentry>
1460           <term><parameter>database</parameter></term>
1461           <listitem>
1462             <para>The database to reconnect, which defaults to the
1463             database indicated by
1464             <symbol>*default-database*</symbol>.</para>
1465           </listitem>
1466         </varlistentry>
1467         <varlistentry>
1468           <term><parameter>error</parameter></term>
1469           <listitem>
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;. 
1473             </para>
1474           </listitem>
1475         </varlistentry>
1476         <varlistentry>
1477           <term><parameter>force</parameter></term>
1478           <listitem>
1479             <para>A Boolean indicating whether to signal an error if the 
1480             database connection has been lost. The default value is &t;. 
1481             </para> 
1482           </listitem>
1483         </varlistentry>
1484         <varlistentry>
1485           <term><parameter>result</parameter></term>
1486           <listitem>
1487             <para>A Boolean indicating whether the database was
1488             successfully reconnected. 
1489             </para> 
1490           </listitem>
1491         </varlistentry>
1492       </variablelist>
1493     </refsect1>
1494     <refsect1>
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> 
1508
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.
1514       </para>
1515     </refsect1>
1516     <refsect1>
1517       <title>Examples</title>
1518       <screen>
1519 *default-database*
1520 => #&lt;CLSQL-SQLITE:SQLITE-DATABASE :memory: OPEN {48CFBEA5}>
1521 (reconnect)
1522 => #&lt;CLSQL-SQLITE:SQLITE-DATABASE :memory: OPEN {48D64105}>
1523       </screen>
1524     </refsect1>
1525     <refsect1>
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>
1530     </refsect1>
1531     <refsect1>
1532       <title>Affected by</title>
1533       <para>
1534         <simplelist>
1535           <member><symbol>*default-database*</symbol></member>
1536         </simplelist>
1537       </para>
1538     </refsect1>
1539     <refsect1>
1540       <title>Exceptional Situations</title>
1541       <para>
1542         An error may be signalled if the specified database cannot be 
1543         located or if the database cannot be closed. 
1544       </para> 
1545     </refsect1>
1546     <refsect1>
1547       <title>See Also</title>
1548       <para>
1549         <simplelist>
1550           <member><link
1551           linkend="connect"><function>connect</function></link></member>
1552           <member><link
1553           linkend="disconnect"><function>disconnect</function></link></member>
1554           <member><link
1555           linkend="disconnect-pooled"><function>disconnect-pooled</function></link></member>
1556         </simplelist>
1557       </para>
1558     </refsect1>
1559     <refsect1>
1560       <title>Notes</title>
1561       <para>
1562         None. 
1563       </para>
1564     </refsect1>
1565   </refentry>
1566
1567   <refentry id="status">
1568     <refmeta>
1569       <refentrytitle>STATUS</refentrytitle>
1570     </refmeta>
1571     <refnamediv>
1572       <refname><emphasis>Function</emphasis> <emphasis role="bold">STATUS</emphasis></refname>
1573       <refpurpose>Print information about connected databases.</refpurpose>
1574       <refclass>Function</refclass>
1575     </refnamediv>
1576     <refsect1>
1577       <title>Syntax</title>
1578       <synopsis>
1579       <function>status</function> &amp;optional <parameter>full</parameter> => <returnvalue></returnvalue></synopsis>
1580     </refsect1>
1581     <refsect1>
1582       <title>Arguments and Values</title>
1583       <variablelist>
1584       <varlistentry>
1585         <term><parameter>full</parameter></term>
1586             <listitem>
1587               <para>A boolean indicating whether to print additional 
1588               table information. The default value is &nil;. 
1589               </para>
1590             </listitem>
1591         </varlistentry>
1592       </variablelist>
1593     </refsect1>
1594     <refsect1>
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
1600       printed.
1601       </para>
1602     </refsect1>
1603     <refsect1>
1604       <title>Examples</title>
1605       <screen>
1606 (status)
1607
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 --------------------------------------------------------
1618
1619 (status t)
1620
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 -------------------------------------------------------------------------------
1631 </screen>
1632     </refsect1>
1633     <refsect1>
1634       <title>Side Effects</title>
1635       <para>
1636         None. 
1637       </para>
1638     </refsect1>
1639     <refsect1>
1640       <title>Affected by</title>
1641       <para>
1642         None. 
1643       </para>
1644     </refsect1>
1645     <refsect1>
1646       <title>Exceptional Situations</title>
1647       <para>
1648         None. 
1649       </para>
1650     </refsect1>
1651     <refsect1>
1652       <title>See Also</title>
1653       <para>
1654         <simplelist>
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>
1660         </simplelist>
1661       </para>
1662     </refsect1>
1663     <refsect1>
1664       <title>Notes</title>
1665       <para>
1666         None. 
1667       </para>
1668     </refsect1>
1669   </refentry>
1670
1671
1672   <!-- create/probe/list/destroytruncate-database --> 
1673
1674   <refentry id="create-database">
1675     <refmeta>
1676       <refentrytitle>CREATE-DATABASE</refentrytitle>
1677     </refmeta>
1678     <refnamediv>
1679       <refname><emphasis>Function</emphasis> <emphasis role="bold">CREATE-DATABASE</emphasis></refname>
1680         <refpurpose>create a database</refpurpose>
1681         <refclass>Function</refclass>
1682       </refnamediv>
1683       <refsect1>
1684         <title>Syntax</title>
1685         <synopsis><function>create-database</function> <replaceable>connection-spec</replaceable> &amp;key <replaceable>database-type</replaceable> => <returnvalue>success</returnvalue></synopsis>
1686       </refsect1>
1687       <refsect1>
1688         <title>Arguments and Values</title>
1689         <variablelist>
1690           <varlistentry>
1691             <term><parameter>connection-spec</parameter></term>
1692             <listitem>
1693               <para>A connection specification</para>
1694             </listitem>
1695           </varlistentry>
1696           <varlistentry>
1697             <term><parameter>database-type</parameter></term>
1698             <listitem>
1699               <para>A database type specifier, i.e. a keyword.
1700                 This defaults to the value of
1701                 <symbol>*default-database-type*</symbol></para>
1702             </listitem>
1703           </varlistentry>
1704           <varlistentry>
1705             <term><parameter>success</parameter></term>
1706             <listitem>
1707               <para>A boolean flag. If &t;, a new database was
1708               successfully created.
1709               </para>
1710             </listitem>
1711           </varlistentry>
1712         </variablelist>
1713       </refsect1>
1714       <refsect1>
1715         <title>Description</title>
1716         <para>This function creates a database in the database system
1717         specified by <parameter>database-type</parameter>.
1718         </para>
1719       </refsect1>
1720       <refsect1>
1721         <title>Examples</title>
1722         <screen>
1723 (create-database '("localhost" "new" "dent" "dent") :database-type :mysql)
1724 => T
1725
1726 (create-database '("localhost" "new" "dent" "badpasswd") :database-type :mysql)
1727 =>
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)'
1732   has occurred.
1733   [condition type: CLSQL-ACCESS-ERROR]
1734         </screen>
1735       </refsect1>
1736       <refsect1>
1737         <title>Side Effects</title>
1738         <para>A database will be created on the filesystem of the host.</para>
1739       </refsect1>
1740       <refsect1>
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
1744         fails.</para>
1745       </refsect1>
1746     <refsect1>
1747       <title>See Also</title>
1748       <para>
1749         <simplelist>
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>
1753         </simplelist>
1754       </para>
1755     </refsect1>
1756       <refsect1>
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>
1766         <para> 
1767           <function>create-database</function> is a &clsql; extension.
1768         </para> 
1769       </refsect1>
1770     </refentry>
1771
1772   <refentry id="destroy-database">
1773     <refmeta>
1774       <refentrytitle>DESTROY-DATABASE</refentrytitle>
1775     </refmeta>
1776     <refnamediv>
1777       <refname><emphasis>Function</emphasis> <emphasis role="bold">DESTROY-DATABASE</emphasis></refname>
1778         <refpurpose>destroys a database</refpurpose>
1779         <refclass>Function</refclass>
1780       </refnamediv>
1781       <refsect1>
1782         <title>Syntax</title>
1783         <synopsis><function>destroy-database</function> <replaceable>connection-spec</replaceable> &amp;key <replaceable>database-type</replaceable> => <returnvalue>success</returnvalue></synopsis>
1784       </refsect1>
1785       <refsect1>
1786         <title>Arguments and Values</title>
1787         <variablelist>
1788           <varlistentry>
1789             <term><parameter>connection-spec</parameter></term>
1790             <listitem>
1791               <para>A connection specification</para>
1792             </listitem>
1793           </varlistentry>
1794           <varlistentry>
1795             <term><parameter>database-type</parameter></term>
1796             <listitem>
1797               <para>A database type specifier, i.e. a keyword.
1798                 This defaults to the value of
1799                 <symbol>*default-database-type*</symbol></para>
1800             </listitem>
1801           </varlistentry>
1802           <varlistentry>
1803             <term><parameter>success</parameter></term>
1804             <listitem>
1805               <para>A boolean flag. If &t;, the database was
1806               successfully destroyed.
1807               </para>
1808             </listitem>
1809           </varlistentry>
1810         </variablelist>
1811       </refsect1>
1812       <refsect1>
1813         <title>Description</title>
1814         <para>This function destroys a database in the database system
1815         specified by <parameter>database-type</parameter>.
1816         </para>
1817       </refsect1>
1818       <refsect1>
1819         <title>Examples</title>
1820         <screen>
1821 (destroy-database '("localhost" "new" "dent" "dent") :database-type :postgresql)
1822 => T
1823
1824 (destroy-database '("localhost" "new" "dent" "dent") :database-type :postgresql)
1825 =>
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
1829   has occurred.
1830   [condition type: CLSQL-ACCESS-ERROR]
1831         </screen>
1832       </refsect1>
1833       <refsect1>
1834         <title>Side Effects</title>
1835         <para>A database will be removed from the filesystem of the host.</para>
1836       </refsect1>
1837       <refsect1>
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>
1842       </refsect1>
1843     <refsect1>
1844       <title>See Also</title>
1845       <para>
1846         <simplelist>
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>
1850         </simplelist>
1851       </para>
1852     </refsect1>
1853       <refsect1>
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>
1863         <para> 
1864           <function>destroy-database</function> is a &clsql; extension.
1865         </para> 
1866       </refsect1>
1867     </refentry>
1868
1869   <refentry id="probe-database">
1870     <refmeta>
1871       <refentrytitle>PROBE-DATABASE</refentrytitle>
1872     </refmeta>
1873     <refnamediv>
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>
1877       </refnamediv>
1878       <refsect1>
1879         <title>Syntax</title>
1880         <synopsis><function>probe-database</function> <replaceable>connection-spec</replaceable> &amp;key <replaceable>database-type</replaceable> => <returnvalue>success</returnvalue></synopsis>
1881       </refsect1>
1882       <refsect1>
1883         <title>Arguments and Values</title>
1884         <variablelist>
1885           <varlistentry>
1886             <term><parameter>connection-spec</parameter></term>
1887             <listitem>
1888               <para>A connection specification</para>
1889             </listitem>
1890           </varlistentry>
1891           <varlistentry>
1892             <term><parameter>database-type</parameter></term>
1893             <listitem>
1894               <para>A database type specifier, i.e. a keyword.
1895                 This defaults to the value of
1896                 <symbol>*default-database-type*</symbol></para>
1897             </listitem>
1898           </varlistentry>
1899           <varlistentry>
1900             <term><parameter>success</parameter></term>
1901             <listitem>
1902               <para>A boolean flag. If &t;, the database exists
1903               in the database system.
1904               </para>
1905             </listitem>
1906           </varlistentry>
1907         </variablelist>
1908       </refsect1>
1909       <refsect1>
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>.
1914         </para>
1915       </refsect1>
1916       <refsect1>
1917         <title>Examples</title>
1918         <screen>
1919 (probe-database '("localhost" "new" "dent" "dent") :database-type :postgresql)
1920 => T
1921         </screen>
1922       </refsect1>
1923       <refsect1>
1924         <title>Side Effects</title>
1925         <para>None</para>
1926       </refsect1>
1927       <refsect1>
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
1932         system.</para>
1933       </refsect1>
1934     <refsect1>
1935       <title>See Also</title>
1936       <para>
1937         <simplelist>
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>
1941         </simplelist>
1942       </para>
1943     </refsect1>
1944       <refsect1>
1945         <title>Notes</title>
1946         <para>
1947           <function>probe-database</function> is a &clsql; extension.
1948         </para>
1949       </refsect1>
1950     </refentry>
1951
1952  <refentry id="list-databases">
1953     <refmeta>
1954       <refentrytitle>LIST-DATABASES</refentrytitle>
1955     </refmeta>
1956     <refnamediv>
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>
1961     </refnamediv>
1962     <refsect1>
1963       <title>Syntax</title>
1964       <synopsis>
1965       <function>list-databases</function> <parameter>connection-spec</parameter> &amp;key <parameter>database-type</parameter> => <returnvalue>result</returnvalue></synopsis>
1966     </refsect1>
1967     <refsect1>
1968       <title>Arguments and Values</title>
1969       <variablelist>
1970           <varlistentry>
1971             <term><parameter>connection-spec</parameter></term>
1972             <listitem>
1973               <para>A connection specification</para>
1974             </listitem>
1975           </varlistentry>
1976           <varlistentry>
1977             <term><parameter>database-type</parameter></term>
1978             <listitem>
1979               <para>A database type specifier, i.e. a keyword.
1980                 This defaults to the value of
1981                 <symbol>*default-database-type*</symbol></para>
1982             </listitem>
1983           </varlistentry>
1984           <varlistentry>
1985             <term><parameter>result</parameter></term>
1986             <listitem>
1987               <para>A list of matching databases. 
1988               </para>
1989             </listitem>
1990           </varlistentry>
1991       </variablelist>
1992     </refsect1>
1993   <refsect1>
1994       <title>Description</title>
1995       <para>
1996         This function returns a list of databases existing in the
1997         database system specified by
1998         <parameter>database-type</parameter>.
1999       </para>
2000     </refsect1>
2001     <refsect1>
2002       <title>Examples</title>
2003       <screen>
2004 (list-databases '("localhost" "new" "dent" "dent") :database-type :postgresql)
2005 => ("address-book" "sql-test" "template1" "template0" "test1" "dent" "test")
2006       </screen>
2007     </refsect1>
2008     <refsect1>
2009       <title>Side Effects</title>
2010       <para>
2011         None. 
2012       </para>
2013     </refsect1>
2014    <refsect1>
2015       <title>Affected by</title>
2016       <para>
2017         None. 
2018       </para>
2019     </refsect1>
2020     <refsect1>
2021       <title>Exceptional Situations</title>
2022       <para>
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
2026         system.
2027       </para>
2028     </refsect1>
2029     <refsect1>
2030       <title>See Also</title>
2031       <para>
2032         <simplelist>
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>
2036         </simplelist>
2037       </para>
2038     </refsect1>
2039     <refsect1>
2040       <title>Notes</title>
2041       <para>
2042         <function>list-databases</function> is a &clsql; extension.
2043       </para>
2044     </refsect1>
2045   </refentry>
2046
2047
2048   <!-- with-database and with-default-database --> 
2049
2050   <refentry id="with-database">
2051     <refmeta>
2052       <refentrytitle>WITH-DATABASE</refentrytitle>
2053     </refmeta>
2054     <refnamediv>
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>
2059     </refnamediv>
2060     <refsect1>
2061       <title>Syntax</title>
2062       <synopsis>
2063       <function>with-database</function> <replaceable>db-var</replaceable> <replaceable>connection-spec</replaceable> &amp;rest <replaceable>connect-args</replaceable> &amp;body <replaceable>body</replaceable> => <returnvalue>result</returnvalue></synopsis>
2064     </refsect1>
2065     <refsect1>
2066       <title>Arguments and Values</title>
2067       <variablelist>
2068         <varlistentry>
2069           <term><parameter>db-var</parameter></term>
2070           <listitem>
2071             <para>A variable to which the specified database is bound. 
2072             </para>
2073           </listitem>
2074         </varlistentry>
2075         <varlistentry>
2076           <term><parameter>connection-spec</parameter></term>
2077           <listitem>
2078             <para>A vendor specific connection specification supplied
2079             as a list or as a string.</para>
2080           </listitem>
2081         </varlistentry>
2082         <varlistentry>
2083           <term><parameter>connect-args</parameter></term>
2084           <listitem>
2085             <para>Other optional arguments to <function>connect</function>. 
2086             </para>
2087           </listitem>
2088         </varlistentry>
2089         <varlistentry>
2090           <term><parameter>body</parameter></term>
2091           <listitem>
2092             <para>A Lisp code body. 
2093             </para>
2094           </listitem>
2095         </varlistentry>
2096         <varlistentry>
2097           <term><parameter>result</parameter></term>
2098           <listitem>
2099             <para>Determined by the result of executing the last
2100             expression in <parameter>body</parameter>.
2101             </para>
2102           </listitem>
2103         </varlistentry>
2104       </variablelist>
2105     </refsect1>
2106     <refsect1>
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
2113       body.
2114       </para>
2115     </refsect1>
2116     <refsect1>
2117       <title>Examples</title>
2118       <screen>
2119 (connected-databases)
2120 => NIL
2121 (with-database (db '(":memory:") :database-type :sqlite 
2122                 :make-default nil)
2123   (database-name db))
2124 => ":memory:"
2125 (connected-databases)
2126 => NIL
2127       </screen>
2128     </refsect1>
2129     <refsect1>
2130       <title>Side Effects</title>
2131       <para>
2132         See <function>connect</function> and <function>disconnect</function>. 
2133       </para>
2134     </refsect1>
2135     <refsect1>
2136       <title>Affected by</title>
2137       <para>
2138         See <function>connect</function> and <function>disconnect</function>. 
2139       </para>
2140     </refsect1>
2141     <refsect1>
2142       <title>Exceptional Situations</title>
2143       <para>
2144         See <function>connect</function> and <function>disconnect</function>. 
2145       </para>
2146     </refsect1>
2147     <refsect1>
2148       <title>See Also</title>
2149       <para>
2150         <simplelist>
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>
2155         </simplelist>
2156       </para>
2157     </refsect1>
2158     <refsect1>
2159       <title>Notes</title>
2160       <para>
2161         <function>with-database</function> is a &clsql; extension.
2162       </para>
2163     </refsect1>
2164   </refentry>
2165
2166   <refentry id="with-default-database">
2167     <refmeta>
2168       <refentrytitle>WITH-DEFAULT-DATABASE</refentrytitle>
2169     </refmeta>
2170     <refnamediv>
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>
2174     </refnamediv>
2175     <refsect1>
2176       <title>Syntax</title>
2177       <synopsis>
2178       <function>with-default-database</function> <replaceable>database</replaceable> &amp;rest <replaceable>body</replaceable> => <returnvalue>result</returnvalue></synopsis>
2179     </refsect1>
2180     <refsect1>
2181       <title>Arguments and Values</title>
2182       <variablelist>
2183         <varlistentry>
2184           <term><parameter>database</parameter></term>
2185           <listitem>
2186             <para>An active database object. 
2187             </para>
2188           </listitem>
2189         </varlistentry>
2190         <varlistentry>
2191           <term><parameter>body</parameter></term>
2192           <listitem>
2193             <para>A Lisp code body. 
2194             </para>
2195           </listitem>
2196         </varlistentry>
2197         <varlistentry>
2198           <term><parameter>result</parameter></term>
2199           <listitem>
2200             <para>Determined by the result of executing the last
2201             expression in <parameter>body</parameter>.
2202             </para>
2203           </listitem>
2204         </varlistentry>
2205       </variablelist>
2206     </refsect1>
2207     <refsect1>
2208       <title>Description</title>
2209       <para>Perform BODY with DATABASE bound as
2210       *default-database*.
2211       </para>
2212     </refsect1>
2213     <refsect1>
2214       <title>Examples</title>
2215       <screen>
2216 *default-database*
2217 => #&lt;CLSQL-ODBC:ODBC-DATABASE new/dent OPEN {49095CAD}>
2218
2219 (let ((database (clsql:find-database ":memory:")))
2220   (with-default-database (database) 
2221     (database-name *default-database*)))
2222 => ":memory:"
2223       </screen>
2224     </refsect1>
2225     <refsect1>
2226       <title>Side Effects</title>
2227       <para>
2228         None. 
2229       </para>
2230     </refsect1>
2231     <refsect1>
2232       <title>Affected by</title>
2233       <para>
2234         None. 
2235       </para>
2236     </refsect1>
2237     <refsect1>
2238       <title>Exceptional Situations</title>
2239       <para>
2240         Calls to &clsql; functions in <parameter>body</parameter> may signal 
2241         errors if <parameter>database</parameter> is not an active database 
2242         object. 
2243       </para>
2244     </refsect1>
2245     <refsect1>
2246       <title>See Also</title>
2247       <para>
2248         <simplelist>
2249           <member><link linkend="with-database"><function>with-database</function></link></member>
2250           <member><link linkend="default-database"><symbol>*default-database*</symbol></link></member>
2251         </simplelist>
2252       </para>
2253     </refsect1>
2254     <refsect1>
2255       <title>Notes</title>
2256       <para>
2257         <function>with-default-database</function> is a &clsql; extension.
2258       </para>
2259     </refsect1>
2260   </refentry>
2261
2262
2263 </reference>