r9749: more documentation
[clsql.git] / doc / ref-ooddl.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 <!-- Object Oriented Data Definition Language --> 
9 <reference id="ref-ooddl"> 
10   <title>Object Oriented Data Definition Language (OODDL)</title> 
11   <partintro>
12     <para>
13       The Object Oriented Data Definition Language (OODDL) provides
14       access to relational SQL tables using Common Lisp Object System
15       (CLOS) objects.  SQL tables are mapped to CLOS objects with the
16       SQL columns being mapped to slots of the CLOS object.
17     </para>
18     <para> 
19       The mapping between SQL tables and CLOS objects is defined
20       with the macro <link
21       linkend="def-view-class"><function>def-view-class</function></link>. SQL
22       tables are created with <link
23       linkend="create-view-from-class"><function>create-view-from-class</function></link>
24       and SQL tables can be deleted with <link
25       linkend="drop-view-from-class"><function>drop-view-from-class</function></link>.
26     </para>
27     <note>The above functions refer to the Lisp <emphasis>view</emphasis> of the SQL
28     table. This Lisp view should not be confused with SQL <function>VIEW</function> statement.
29     </note>
30   </partintro>
31
32   <refentry id="standard-db-object">
33     <refnamediv>
34       <refname>STANDARD-DB-OBJECT</refname>
35       <refpurpose>Superclass for all &clsql; View Classes.</refpurpose>
36       <refclass>Class</refclass>
37     </refnamediv>
38     <refsect1>
39       <title>Class Precedence List</title>
40       <para>
41         <simplelist type="inline">
42           <member><type>standard-db-object</type></member>
43           <member><type>standard-object</type></member>
44           <member><type>t</type></member>
45         </simplelist>
46       </para>
47     </refsect1>
48     <refsect1>
49       <title>Description</title> <para>This class is the superclass
50       of all &clsql; View Classes.</para>
51     </refsect1>
52     <refsect1>
53       <title class="contenttitle">Class details</title>
54       <programlisting>(defclass STANDARD-DB-OBJECT ()(...))</programlisting>
55     </refsect1>
56     <refsect1>
57       <title class="contenttitle">Slots</title>
58       <para>
59         <simplelist> 
60           <property>slot VIEW-DATABASE is of type (OR NULL DATABASE)
61           which stores the associated database for the
62           instance.</property>
63         </simplelist> 
64       </para>
65     </refsect1>
66   </refentry>
67
68   <refentry id="default-string-length">
69     <refnamediv>
70       <refname>*DEFAULT-STRING-LENGTH*</refname>
71       <refpurpose>Default length of SQL strings.</refpurpose>
72       <refclass>Variable</refclass>
73     </refnamediv>
74     <refsect1>
75       <title>Value Type</title>
76       <para>
77         Fixnum
78       </para> 
79     </refsect1>
80     <refsect1>
81       <title>Initial Value</title>
82       <para><parameter>255</parameter></para>
83     </refsect1>
84     <refsect1>
85       <title>Description</title> 
86       <para>
87         If a slot of a class defined by
88         <function>DEF-VIEW-CLASS</function> is of the type
89         <parameter>STRING</parameter> or <parameter>VARCHAR</parameter> and does
90         not have a length specified, then the value of this variable
91         is used as SQL length.
92       </para>
93     </refsect1>
94     <refsect1>
95       <title>Examples</title>
96       <screen>
97         (let ((*default-string-length* 80))
98         (def-view-class s80 ()
99         ((a :type string)
100         (b :type (string 80))
101         (c :type varchar))))
102         (create-view-from-class 's80)   
103       </screen>
104       <para>
105         The above code causes a SQL table to be created with the SQL command
106       </para>
107       <screen>CREATE TABLE (A VARCHAR(80), B CHAR(80), C VARCHAR(80))</screen>
108     </refsect1>
109     <refsect1>
110       <title>Affected By</title>
111       <para>Some SQL backends do not support <parameter>VARCHAR</parameter>
112       lengths greater than 255 .</para>
113     </refsect1>
114     <refsect1>
115       <title>See Also</title>
116       <para>None.</para>
117     </refsect1>
118     <refsect1>
119       <title>Notes</title>
120       <para>This is a CLSQL extension to the CommonSQL API.</para>
121     </refsect1>
122   </refentry>
123
124   <refentry id="create-view-from-class">
125     <refnamediv>
126       <refname>CREATE-VIEW-FROM-CLASS</refname>
127       <refpurpose>Create a SQL table from a view class.</refpurpose>
128       <refclass>Function</refclass>
129     </refnamediv>
130     <refsect1>
131       <title>Syntax</title>
132       <synopsis>
133       <function> (create-view-from-class view-class-name &amp;key (database *default-database*) (transactions t))</function> => <returnvalue><!-- no values --></returnvalue></synopsis>
134     </refsect1>
135     <refsect1>
136       <title>Arguments and Values</title>
137       <variablelist>
138         <varlistentry>
139           <term><parameter>view-class-name</parameter></term>
140           <listitem>
141             <para>
142               The name of a view class that has been defined with
143               <link linkend="def-view-class"><function>def-view-class</function></link>.
144             </para>
145           </listitem>
146         </varlistentry>
147         <varlistentry>
148           <term><parameter>database</parameter></term>
149           <listitem>
150             <para>
151               The database in which to create the SQL table.
152             </para>
153           </listitem>
154         </varlistentry>
155         <varlistentry>
156           <term><parameter>transactions</parameter></term>
157           <listitem>
158             <para>
159               When &nil; specifies that a table type which does not support transactions should be used.
160             </para>
161           </listitem>
162         </varlistentry>
163       </variablelist>
164     </refsect1>
165     <refsect1>
166       <title>Description</title>
167       <para>
168         Creates a table as defined by the View Class
169         <parameter>view-class-name</parameter> in <parameter>database</parameter>.
170       </para>
171     </refsect1>
172     <refsect1>
173       <title>Examples</title>
174       <screen>
175         * (def-view-class 'foo () ((a :type (string 80))))
176         #&lt;CLSQL-SYS::STANDARD-DB-CLASS FOO>
177         * (create-view-from-class 'foo)
178         * (list-tables)
179         ("FOO")
180       </screen>
181     </refsect1>
182     <refsect1>
183       <title>Side Effects</title>
184       <para>
185         Causes a table to be created in the SQL database.
186       </para>
187     </refsect1>
188     <refsect1>
189       <title>Affected by</title>
190       <para>
191         Most SQL database systems will signal an error if a table
192         creation is attempted when a table with the same name already
193         exists. The SQL user, as specified in the database connection,
194         must have sufficient permission for table creation.
195       </para>
196     </refsect1>
197     <refsect1>
198       <title>Exceptional Situations</title>
199       <para>
200         A condition will be signaled if the table can not be created
201         in the SQL database.
202       </para>
203     </refsect1>
204     <refsect1>
205       <title>See Also</title>
206       <para>
207         <simplelist>
208           <member><link linkend="def-view-class"><function>def-view-class</function></link></member>
209           <member><link linkend="drop-view-from-class"><function>drop-view-from-class</function></link></member>
210         </simplelist>
211       </para>
212     </refsect1>
213     <refsect1>
214       <title>Notes</title>
215       <para>
216         Currently, only &mysql; supports transactionless
217         tables. &clsql; provides the ability to create such tables for
218         applications which would benefit from faster table access and
219         do not require transaction support.
220       </para>
221       <para>
222         The case of the table name is determined by the type of the
223         database. &mysql;, for example, creates databases in upper-case
224         while &postgresql; uses lowercase.
225       </para>
226     </refsect1>
227   </refentry>
228
229   <refentry id="def-view-class">
230     <refnamediv>
231       <refname>DEF-VIEW-CLASS</refname>
232       <refpurpose>Defines CLOS classes with mapping to SQL database.</refpurpose>
233       <refclass>Macro</refclass>
234     </refnamediv>
235     <refsect1>
236       <title>Syntax</title>
237       <synopsis>
238       <function>(def-view-class name superclasses slots &amp;rest class-options)</function> => <returnvalue>class</returnvalue></synopsis>
239     </refsect1>
240     <refsect1>
241       <title>Arguments and Values</title>
242       <variablelist>
243         <varlistentry>
244           <term><parameter>name</parameter></term>
245           <listitem>
246             <para>
247               The class name.
248             </para>
249           </listitem>
250         </varlistentry>
251         <varlistentry>
252           <term><parameter>name</parameter></term>
253           <listitem>
254             <para>
255               The superclasses for the defined class.
256             </para>
257           </listitem>
258         </varlistentry>
259         <varlistentry>
260           <term><parameter>slots</parameter></term>
261           <listitem>
262             <para>
263               The class slot definitions.
264             </para>
265           </listitem>
266         </varlistentry>
267         <varlistentry>
268           <term><parameter>class</parameter></term>
269           <listitem>
270             <para>
271               The defined class.
272             </para>
273           </listitem>
274         </varlistentry>
275       </variablelist>
276     </refsect1>
277     <refsect1>
278       <title>Slot Options</title>
279       <itemizedlist>
280         <listitem>
281           <para>
282             <parameter>:db-kind</parameter> - specifies the kind of
283             database mapping which is performed for this slot and defaults
284             to <parameter>:base</parameter> which indicates that the
285             slot maps to an ordinary column of the database table. A
286             <parameter>:db-kind</parameter> value of
287             <parameter>:key</parameter> indicates that this slot is
288             a special kind of <parameter>:base</parameter> slot
289             which maps onto a column which is one of the unique keys
290             for the database table, the value
291             <parameter>:join</parameter> indicates this slot
292             represents a join onto another View Class which contains
293             View Class objects, and the value
294             <parameter>:virtual</parameter> indicates a standard
295             CLOS slot which does not map onto columns of the
296             database table.
297           </para>
298         </listitem>
299         <listitem>
300           <para>
301             <parameter>:db-info</parameter> - if a slot is specified with
302             <parameter>:db-kind</parameter> <parameter>:join</parameter>, the
303             slot option <parameter>:db-info</parameter> contains a property list
304             which specifies the nature of the join. The valid members of the list
305             are:
306           </para>
307           <itemizedlist>
308             <listitem>
309               <para>
310                 <parameter>:join-class</parameter>
311                 <emphasis>class-name</emphasis> - the name of the
312                 class to join on.
313               </para>
314             </listitem>
315             <listitem>
316               <para>
317                 <parameter>:home-key</parameter>
318                 <emphasis>slot-name</emphasis> - the name of the slot
319                 of this class for joining
320               </para>
321             </listitem>
322             <listitem>
323               <para>
324                 <parameter>:foreign-key</parameter>
325                 <emphasis>slot-name</emphasis> - the name of the slot
326                 of the <parameter>:join-class</parameter> for joining
327               </para>
328             </listitem>
329             <listitem>
330               <para>
331                 <parameter>:target-slot</parameter>
332                 <emphasis>target-slot</emphasis> - this is an optional
333                 parameter. If specified, then the join slot of the
334                 defining class will contain instances of this target
335                 slot rather than of the join class. This can be useful
336                 when the <parameter>:join-class</parameter> is an
337                 intermediate class in a
338                 <emphasis>many-to-many</emphasis> relationship and the
339                 application is actually interested in the
340                 <parameter>:target-slot</parameter>.
341               </para>
342             </listitem>
343             <listitem>
344               <para>
345                 <parameter>:retrieval</parameter>
346                 <emphasis>time</emphasis> - The default value is
347                 <parameter>:deferred</parameter>, which defers filling
348                 this slot until the value is accessed. The other valid
349                 value is <parameter>:immediate</parameter> which
350                 performs the SQL query when the instance of the class
351                 is created. In this case, the
352                 <parameter>:set</parameter> is automatically set to
353                 &nil;
354               </para>
355             </listitem>
356             <listitem>
357               <para>
358                 <parameter>:set</parameter>
359                 <emphasis>set</emphasis> - This controls what is stored in the join slot.
360                 The default value is &t;. When <emphasis>set</emphasis> is &t; and 
361                 <emphasis>target-slot</emphasis> is undefined, the join slot will contain
362                 a list of instances of the join class. Whereas, if <emphasis>target-slot</emphasis> is defined, 
363                 then the join slot will contain a list of pairs of <emphasis>(target-value join-instance)</emphasis>.
364                 When <emphasis>set</emphasis> is &nil;, the join slot will contain a single instances.
365               </para>
366             </listitem>
367           </itemizedlist>
368         </listitem>
369         <listitem>
370           <para>
371             <parameter>:type</parameter> - for slots of
372             <parameter>:db-kind</parameter> <parameter>:base</parameter> or
373             <parameter>:key</parameter>, the <parameter>:type</parameter> slot
374             option has a special interpretation such that Lisp
375             types, such as string, integer and float are
376             automatically converted into appropriate SQL types for
377             the column onto which the slot maps. This behaviour may
378             be overridden using the <parameter>:db-type</parameter> slot
379             option. The valid values are:
380             <simplelist>
381               <member>
382                 <parameter>string</parameter> - a variable length character field up to
383                 <link linkend="default-string-length">*default-string-length*</link> characters.
384               </member>
385               <member>
386                 <parameter>(string n)</parameter> - a fixed length character field  
387                 <parameter>n</parameter> characters long.
388               </member>
389               <member>
390                 <parameter>varchar</parameter> - a variable length character field up to
391                 <link linkend="default-string-length">*default-string-length*</link> characters.
392               </member>
393               <member>
394                 <parameter>(varchar n)</parameter> - a variable length character field up to
395                 <parameter>n</parameter> characters in length.
396               </member>
397               <member>
398                 <parameter>char</parameter> - a single character field 
399               </member>
400               <member><parameter>integer</parameter> - signed integer at least 32-bits wide</member>
401               <member><parameter>(integer n)</parameter></member>
402               <member><parameter>float</parameter></member>
403               <member><parameter>(float n)</parameter></member>
404               <member><parameter>long-float</parameter></member>
405               <member><parameter>number</parameter></member>
406               <member><parameter>(number n)</parameter></member>
407               <member><parameter>(number n p)</parameter></member>
408               <member>
409                 <parameter>smallint</parameter> - An integer column 16-bits
410                 wide. [not supported by all database backends]
411               </member>
412               <member>
413                 <parameter>bigint</parameter> - An integer column 
414                 64-bits wide. [not supported by all database backends]
415               </member>
416               <member>
417                 <parameter>universal-time</parameter> - an integer
418                 field sufficiently wide to store a
419                 universal-time. On most databases, a slot of this
420                 type assigned a SQL type of
421                 <parameter>BIGINT</parameter>
422               </member>
423               <member>
424                 <parameter>wall-time</parameter> - a slot which
425                 stores a date and time in a SQL timestamp
426                 column. &clsql; provides a number of time
427                 manipulation functions to support objects of type
428                 <type>wall-time</type>.
429               </member>
430               <member>
431                 <parameter>duration</parameter> - stores a <type>duration</type> structure.
432                 &clsql; provides routines for <type>wall-time</type> and <type>duration</type>
433                 processing.
434               </member>
435               <member><parameter>boolean</parameter> - stores a &t; or &nil; value.</member>
436               <member>
437                 <parameter>generalized-boolean</parameter> - similar
438                 to a <parameter>boolean</parameter> in that either a
439                 &t; or &nil; value is stored in the SQL
440                 database. However, any Lisp object can be stored in
441                 the Lisp object. A Lisp value of &nil; is stored as
442                 <constant>FALSE</constant> in the database, any
443                 other Lisp value is stored as
444                 <constant>TRUE</constant>.
445               </member>
446               <member>
447                 <parameter>keyword</parameter> - stores a keyword
448               </member> 
449               <member><parameter>symbol</parameter> - stores a symbol</member>
450               <member>
451                 <parameter>list</parameter> - stores a list by writing it to a string. The items
452                 in the list must be able to be readable written.
453               </member>
454               <member><parameter>vector</parameter> - stores a vector similarly to <parameter>list</parameter></member>
455               <member><parameter>array</parameter> - stores a array similarly to <parameter>list</parameter></member>
456             </simplelist>
457           </para>
458           
459         </listitem>
460         <listitem>
461           <para>
462             <parameter>:column</parameter> - specifies the name of
463             the SQL column which the slot maps onto, if
464             <parameter>:db-kind</parameter> is not
465             <parameter>:virtual</parameter>, and defaults to the
466             slot name. If the slot name is used for the SQL column
467             name, any hypens in the slot name are converted
468             to underscore characters.
469           </para>
470         </listitem>
471         <listitem>
472           <para>
473             <parameter>:void-value</parameter> - specifies
474             the value to store in the Lisp instance if the SQL value is NULL and defaults
475             to NIL.
476           </para>
477         </listitem>
478         <listitem>
479           <para>
480             <parameter>:db-constraints</parameter> - is a string
481             representing an SQL table constraint expression or a
482             list of such strings.
483           </para>
484         </listitem>
485         <listitem>
486           <para>
487             <parameter>:db-type</parameter> - a string to specify the SQL
488             column type. If specified, this string overrides the SQL
489             column type as computed from the <parameter>:type</parameter>
490             slot value.
491           </para>
492         </listitem>
493       </itemizedlist>
494     </refsect1>
495     <refsect1>
496       <title>Class Options</title>
497       <para>
498         <itemizedlist>
499           <listitem>
500             <para>
501               <parameter>:base-table</parameter> - specifies the name of the
502               SQL database table. The default value is the class name. Like slot names,
503               hypens in the class name are converted to underscore characters.
504             </para>
505           </listitem>
506         </itemizedlist>
507       </para>
508     </refsect1>
509     <refsect1>
510       <title>Description</title>
511       <para>
512         Creates a View Class called <parameter>name</parameter> whose
513         slots <parameter>slots</parameter> can map onto the attributes
514         of a table in a database. If
515         <parameter>superclasses</parameter> is &nil; then the
516         superclass of <parameter>class</parameter> will be
517         <parameter>standard-db-object</parameter>, otherwise
518         <parameter>superclasses</parameter> is a list of superclasses
519         for <parameter>class</parameter> which must include
520         <parameter>standard-db-object</parameter> or a descendent of this
521         class.
522       </para>
523
524     </refsect1>
525     <refsect1>
526       <title>Examples</title>
527       <para>
528         The following examples are from the &clsql; test suite.
529       </para>
530       <screen>
531 (def-view-class person (thing)
532   ((height :db-kind :base :accessor height :type float
533            :initarg :height)
534    (married :db-kind :base :accessor married :type boolean
535             :initarg :married)
536    (birthday :type clsql:wall-time :initarg :birthday)
537    (bd-utime :type clsql:universal-time :initarg :bd-utime)
538    (hobby :db-kind :virtual :initarg :hobby :initform nil)))
539   
540 (def-view-class employee (person)
541   ((emplid
542     :db-kind :key
543     :db-constraints :not-null
544     :type integer
545     :initarg :emplid)
546    (groupid
547     :db-kind :key
548     :db-constraints :not-null
549     :type integer
550     :initarg :groupid)
551    (first-name
552     :accessor first-name
553     :type (varchar 30)
554     :initarg :first-name)
555    (last-name
556     :accessor last-name
557     :type (varchar 30)
558     :initarg :last-name)
559    (email
560     :accessor employee-email
561     :type (varchar 100)
562     :initarg :email)
563    (ecompanyid
564     :type integer
565     :initarg :companyid)
566    (company
567     :accessor employee-company
568     :db-kind :join
569     :db-info (:join-class company
570                           :home-key ecompanyid
571                           :foreign-key companyid
572                           :set nil))
573    (managerid
574     :type integer
575     :initarg :managerid)
576    (manager
577     :accessor employee-manager
578     :db-kind :join
579     :db-info (:join-class employee
580                           :home-key managerid
581                           :foreign-key emplid
582                           :set nil))
583    (addresses
584     :accessor employee-addresses
585     :db-kind :join
586     :db-info (:join-class employee-address
587                           :home-key emplid
588                           :foreign-key aemplid
589                           :target-slot address
590                           :set t)))
591   (:base-table employee))
592
593 (def-view-class company ()
594   ((companyid
595     :db-kind :key
596     :db-constraints :not-null
597     :type integer
598     :initarg :companyid)
599    (groupid
600     :db-kind :key
601     :db-constraints :not-null
602     :type integer
603     :initarg :groupid)
604    (name
605     :type (varchar 100)
606     :initarg :name)
607    (presidentid
608     :type integer
609     :initarg :presidentid)
610    (president
611     :reader president
612     :db-kind :join
613     :db-info (:join-class employee
614                           :home-key presidentid
615                           :foreign-key emplid
616                           :set nil))
617    (employees
618     :reader company-employees
619     :db-kind :join
620     :db-info (:join-class employee
621                           :home-key (companyid groupid)
622                           :foreign-key (ecompanyid groupid)
623                           :set t))))
624
625 (def-view-class address ()
626   ((addressid
627     :db-kind :key
628     :db-constraints :not-null
629     :type integer
630     :initarg :addressid)
631    (street-number
632     :type integer
633     :initarg :street-number)
634    (street-name
635     :type (varchar 30)
636     :void-value ""
637     :initarg :street-name)
638    (city
639     :column "city_field"
640     :void-value "no city"
641     :type (varchar 30)
642     :initarg :city)
643    (postal-code
644     :column zip
645     :type integer
646     :void-value 0
647     :initarg :postal-code))
648   (:base-table addr))
649
650 ;; many employees can reside at many addressess
651 (def-view-class employee-address ()
652   ((aemplid :type integer :initarg :emplid)
653    (aaddressid :type integer :initarg :addressid)
654    (verified :type boolean :initarg :verified)
655    (address :db-kind :join
656             :db-info (:join-class address
657                                   :home-key aaddressid
658                                   :foreign-key addressid
659                                   :retrieval :immediate)))
660   (:base-table "ea_join"))
661
662 (def-view-class deferred-employee-address ()
663   ((aemplid :type integer :initarg :emplid)
664    (aaddressid :type integer :initarg :addressid)
665    (verified :type boolean :initarg :verified)
666    (address :db-kind :join
667             :db-info (:join-class address
668                                   :home-key aaddressid
669                                   :foreign-key addressid
670                                   :retrieval :deferred
671                                   :set nil)))
672   (:base-table "ea_join"))
673       </screen>
674     </refsect1>
675     <refsect1>
676       <title>Side Effects</title>
677       <para>Creates a new CLOS class.</para>
678     </refsect1>
679     <refsect1>
680       <title>Affected by</title>
681       <para>
682         Nothing.
683       </para>
684     </refsect1>
685     <refsect1>
686       <title>Exceptional Situations</title>
687       <para>
688         None.
689       </para>
690     </refsect1>
691     <refsect1>
692       <title>See Also</title>
693       <para>
694         <simplelist>
695           <member><link linkend="create-view-from-class"><function>create-view-from-class</function></link></member>
696           <member><link linkend="standard-db-object"><parameter>standard-db-object</parameter></link></member>
697           <member><link linkend="drop-view-from-class"><function>drop-view-from-class</function></link></member>
698         </simplelist>
699       </para>
700     </refsect1>
701     <refsect1>
702       <title>Notes</title>
703       <para>
704         The actual SQL type for a column depends up the database type
705         in which the SQL table is stored. As an example, the view
706         class type <parameter>(varchar 100)</parameter> specifies a
707         SQL column type <parameter>VARCHAR(100)</parameter> in &mysql;
708         and a column type <parameter>VARCHAR2(100)</parameter> in
709         &oracle;
710       </para>
711       <para>
712         The actual lisp type for a slot may be different than the
713         value specified by the <parameter>:type</parameter> attribute.
714         For example, a slot declared with "<parameter>:type (string
715         30)</parameter>" actually sets the slots Lisp type as
716         <parameter>(or null string)</parameter>. This is to allow a
717         &nil; value or a string shorter than 30 characters to be
718         stored in the slot.
719       </para>
720     </refsect1>
721   </refentry>
722
723   <refentry id="drop-view-from-class">
724     <refnamediv>
725       <refname>DROP-VIEW-FROM-CLASS</refname>
726       <refpurpose>Delete table from SQL database.</refpurpose>
727       <refclass>Function</refclass>
728     </refnamediv>
729     <refsect1>
730       <title>Syntax</title>
731       <synopsis>
732       <function>(drop-view-from-class view-class-name &amp;key (database *default-database*))</function> => <returnvalue><!-- result --></returnvalue></synopsis>
733     </refsect1>
734     <refsect1>
735       <title>Arguments and Values</title>
736       <variablelist>
737         <varlistentry>
738           <term><parameter>view-class-name</parameter></term>
739           <listitem>
740             <para>
741               The name of the view class.
742             </para>
743           </listitem>
744         </varlistentry>
745       </variablelist>
746     </refsect1>
747     <refsect1>
748       <title>Description</title>
749       <para>Removes a table defined by the View Class
750       <parameter>VIEW-CLASS-NAME</parameter> from
751       <parameter>DATABASE</parameter> which defaults to
752       <parameter>*DEFAULT-DATABASE*</parameter>.
753       </para>
754     </refsect1>
755     <refsect1>
756       <title>Examples</title>
757       <screen>
758         * (list-tables)
759         ("FOO" "BAR")   
760         * (drop-view-from-class 'foo)
761         * (list-tables)
762         ("BAR") 
763       </screen>
764     </refsect1>
765     <refsect1>
766       <title>Side Effects</title>
767       <para>
768         Deletes a table from the SQL database.
769       </para>
770     </refsect1>
771     <refsect1>
772       <title>Affected by</title>
773       <para>
774         Whether the specified table exists in the SQL database.
775       </para>
776     </refsect1>
777     <refsect1>
778       <title>Exceptional Situations</title>
779       <para>
780         A condition may be signalled if the table does not exist in
781         the SQL database or if the SQL connection does not have
782         sufficient permissions to delete tables.
783       </para>
784     </refsect1>
785     <refsect1>
786       <title>See Also</title>
787       <para>
788         <simplelist>
789           <member><link linkend="create-view-from-class"><function>create-view-from-class</function></link></member>
790           <member><link linkend="def-view-class"><function>def-view-class</function></link></member>
791         </simplelist>
792       </para>
793     </refsect1>
794     <refsect1>
795       <title>Notes</title>
796       <para>
797         <!-- notes --> 
798       </para>
799     </refsect1>
800   </refentry>
801
802   <refentry id="list-classes">
803     <refnamediv>
804       <refname>LIST-CLASSES</refname>
805       <refpurpose>List classes for tables in SQL database.</refpurpose>
806       <refclass>Function</refclass>
807     </refnamediv>
808     <refsect1>
809       <title>Syntax</title>
810       <synopsis>
811       <function>(list-classes &amp;key (test #'identity) (root-class (find-class 'standard-db-object)) (database *default-database*))</function> => <returnvalue>classes</returnvalue></synopsis>
812     </refsect1>
813     <refsect1>
814       <title>Arguments and Values</title>
815       <variablelist>
816         <varlistentry>
817           <term><parameter>test</parameter></term>
818           <listitem>
819             <para>
820               a function used to filter the search. By default, <parameter>identity</parameter> is used which
821               will return all classes.
822             </para>
823           </listitem>
824         </varlistentry>
825         <varlistentry>
826           <term><parameter>root-class</parameter></term>
827           <listitem>
828             <para>
829               specifies the root class to the search. By default, <parameter>standard-db-object</parameter> is used
830               which is the root for all view classes.
831             </para>
832           </listitem>
833         </varlistentry>
834         <varlistentry>
835           <term><parameter>database</parameter></term>
836           <listitem>
837             <para>
838               The database to search for view classes.
839             </para>
840           </listitem>
841         </varlistentry>
842         <varlistentry>
843           <term><parameter>classes</parameter></term>
844           <listitem>
845             <para>
846               List of view classes.
847             </para>
848           </listitem>
849         </varlistentry>
850       </variablelist>
851     </refsect1>
852     <refsect1>
853       <title>Description</title>
854       <para>Returns a list of all the View Classes which have been
855       defined in the Lisp session and are connected to
856       <parameter>database</parameter> and which descended from the
857       class <parameter>root-class</parameter> and which satisfy the
858       function <parameter>test</parameter>.
859       </para>
860     </refsect1>
861     <refsect1>
862       <title>Examples</title>
863       <screen>
864         * (list-classes)
865         (#&lt;clsql-sys::standard-db-class big> #&lt;clsql-sys::standard-db-class employee-address>
866         #&lt;clsql-sys::standard-db-class address> #&lt;clsql-sys::standard-db-class company> 
867         #&lt;clsql-sys::standard-db-class employee>)
868
869         * (list-classes :test #'(lambda (c) (> (length (symbol-name (class-name c))) 3)))
870         (#&lt;clsql-sys::standard-db-class employee-address> #&lt;clsql-sys::standard-db-class address>
871         #&lt;clsql-sys::standard-db-class company> #&lt;clsql-sys::standard-db-class employee>)
872       </screen>
873     </refsect1>
874     <refsect1>
875       <title>Side Effects</title>
876       <para>
877         None.
878       </para>
879     </refsect1>
880     <refsect1>
881       <title>Affected by</title>
882       <para>
883         <simplelist>
884           Which view classes have been defined in the Lisp session.
885         </simplelist>
886       </para>
887     </refsect1>
888     <refsect1>
889       <title>Exceptional Situations</title>
890       <para>
891         None.
892       </para>
893     </refsect1>
894     <refsect1>
895       <title>See Also</title>
896       <para>
897         <simplelist>
898           <member><link linkend="def-view-class"><function>def-view-class</function></link></member>
899         </simplelist>
900       </para>
901     </refsect1>
902   </refentry>
903
904
905 </reference>