2 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
4 <!ENTITY % myents SYSTEM "entities.inc">
8 <!-- Object Oriented Data Manipulation Language -->
9 <reference id="ref-oodml">
10 <title>Object Oriented Data Manipulation Language (OODML)</title>
13 Object Oriented Data Manipulation Language (OODML) provides a Common Lisp
14 Object System (CLOS) interface to SQL databases. View classes are defined with
15 the <link linkend="ref-ooddl">OODDL</link> interface and objects are read and
16 written with the OODML.
19 The main function for reading data with the OODML is the
20 <link linkend="select"><function>select</function></link> function. The
21 <function>select</function> is also used in the FDML. However, when <function>select</function>
22 is given a view class name, it returns a list of instances of view classes.
26 <refentry id="db-auto-sync">
28 <refname>*DB-AUTO-SYNC*</refname>
29 <refpurpose>Enables SQL storage during Lisp object creation.</refpurpose>
30 <refclass>Variable</refclass>
33 <title>Value Type</title>
39 <title>Initial Value</title>
43 <title>Description</title>
44 When this variable is &t; an instance is stored in the SQL database when the instance is created
45 by <function>make-instance</function>. When this variable is &nil;, which is the default value, &clsql;
46 behaves like &commonsql;: instances of view classes are stored to the SQL database only when
47 <link linkend="update-record-from-slots"><function>update-record-from-slots</function></link>
51 <title>Examples</title>
53 (let ((instance (make-instance 'foo)))
54 (update-record-from-slots instance))
58 (let ((*db-auto-sync* t))
63 <title>Affected By</title>
67 <title>See Also</title>
69 <member><link linkend="update-record-from-slots"><function>update-record-from-slots</function></link></member>
78 <refentry id="default-update-objects-max-len">
80 <refname>*DEFAULT-UPDATE-OBJECTS-MAX-LEN*</refname>
81 <refpurpose>The default maximum number of objects each query to perform a join</refpurpose>
82 <refclass>Variable</refclass>
85 <title>Value Type</title>
91 <title>Initial Value</title>
95 <title>Description</title>
97 This special variable provides the default value for the
98 <parameter>max-len</parameter> argument of the function <link
99 linkend="update-object-joins"><function>update-object-joins</function></link>.
103 <title>Examples</title>
105 (setq *default-update-objects-max-len* 100)
109 <title>Affected By</title>
113 <title>See Also</title>
122 <refentry id="delete-instance-records">
124 <refname>DELETE-INSTANCE-RECORDS</refname>
125 <refpurpose>Delete SQL records represented by a view class object.</refpurpose>
126 <refclass>Function</refclass>
129 <title>Syntax</title>
131 <function>(delete-instance-records object)</function> => <returnvalue><!-- result --></returnvalue></synopsis>
134 <title>Arguments and Values</title>
137 <term><parameter>object</parameter></term>
140 An instance of a view class.
147 <title>Description</title>
148 <para>Deletes the records represented by
149 <parameter>object</parameter> in the appropriate table of the
150 database associated with <parameter>object</parameter>. If
151 <parameter>object</parameter> is not yet associated with a
152 database, an error is signalled.
156 <title>Examples</title>
158 * (def-view-class tab () ((a :type integer :db-kind :key) (b :type string)))
159 #<clsql-sys::db-standard-class tab>
160 * (defvar obj (let ((*db-auto-sync* t))
161 (make-instance 'tab :a 5 :b "the string")))
162 * (start-sql-recording :type :both)
163 * (delete-instance-records obj)
167 <title>Side Effects</title>
169 Deletes data from the SQL database.
173 <title>Affected by</title>
175 Permissions granted by the SQL database to the user in the database connection.
179 <title>Exceptional Situations</title>
181 An exception may be signaled if the database connection user does not have
182 sufficient privileges to modify the database.
186 <title>See Also</title>
189 <member><link linkend="update-records"><function>update-records</function></link></member>
190 <member><link linkend="update-records-from-instance"><function>update-records-from-instance</function></link></member>
197 Instances are referenced in the database by values stored in the key slots. If
198 <function>delete-records-from-instance</function> is called with an instance of a class that does
199 not contain any keys, then all records in that table will be deleted.
204 <refentry id="instance-refreshed">
206 <refname>INSTANCE-REFRESHED</refname>
207 <refpurpose>User hook to call on object refresh.</refpurpose>
208 <refclass>Generic function</refclass>
211 <title>Syntax</title>
213 <function>(instance-refreshed object)</function> => <returnvalue><!-- result --></returnvalue></synopsis>
216 <title>Arguments and Values</title>
219 <term><parameter>object</parameter></term>
222 The view class object which is being refreshed.
229 <title>Description</title>
230 <para>Provides a hook which is called within an object oriented
231 call to <function>select</function> with a non-nil value of
232 <parameter>refresh</parameter> when the View Class instance
233 <parameter>object</parameter> has been updated from the
234 database. A method specialised on
235 <type>standard-db-object</type> is provided which has no
236 effects. Methods specialised on particular View Classes can be
237 used to specify any operations that need to be made on View
238 Classes instances which have been updated in calls to
239 <function>select</function>.
243 <title>Examples</title>
249 <title>Side Effects</title>
251 The user hook function may cause side effects.
255 <title>Exceptional Situations</title>
261 <title>See Also</title>
264 <member><link linkend="select"><function>select</function></link></member>
270 <refentry id="update-instance-from-records">
272 <refname>UPDATE-INSTANCE-FROM-RECORDS</refname>
273 <refpurpose>Update slot values from database.</refpurpose>
274 <refclass>Function</refclass>
277 <title>Syntax</title>
279 <function>(update-instance-from-records object &key database)</function> => <returnvalue><!-- result --></returnvalue></synopsis>
282 <title>Arguments and Values</title>
285 <term><parameter>object</parameter></term>
288 An instance of a view class.
293 <term><parameter>database</parameter></term>
296 A database connection.
303 <title>Description</title>
304 <para>Updates the slot values of the View Class instance
305 <parameter>object</parameter> using the attribute values of the
306 appropriate table of <parameter>database</parameter> which
307 defaults to the database associated with
308 <parameter>object</parameter> or, if <parameter>object</parameter> is not associated
309 with a database, <variable>*default-database*</variable>. Join slots are updated but
310 instances of the class on which the join is made are not
315 <title>Examples</title>
321 <title>Side Effects</title>
323 Slot values of <parameter>object</parameter> may be modified.
327 <title>Affected by</title>
330 Data in SQL database.
335 <title>Exceptional Situations</title>
337 If <parameter>database</parameter> is not able to be read.
341 <title>See Also</title>
356 <refentry id="update-objects-joins">
358 <refname>UPDATE-OBJECTS-JOINS</refname>
359 <refpurpose>Updates joined slots of objects.</refpurpose>
360 <refclass>Function</refclass>
363 <title>Syntax</title>
365 <function>(update-objects-joins objects &key (slots t) (force-p t) class-name (max-len *default-update-objects-max-len*))</function> => <returnvalue><!-- result --></returnvalue></synopsis>
368 <title>Arguments and Values</title>
371 <term><parameter>objects</parameter></term>
374 A list of instances of a view class.
379 <term><parameter>slots</parameter></term>
386 <term><parameter>force-p</parameter></term>
393 <term><parameter>class-name</parameter></term>
396 A list of instances of a view class.
401 <term><parameter>max-len</parameter></term>
410 <title>Description</title>
411 <para>Updates from the records of the appropriate database
412 tables the join slots specified by <parameter>slots</parameter>
413 in the supplied list of View Class instances
414 <parameter>objects</parameter>. <parameter>slots</parameter>
415 when &t; means that all join slots with :retrieval :immediate
416 are updated. <parameter>class-name</parameter> is used to
417 specify the View Class of all instance in
418 <parameter>objects</parameter>, when &nil; then the class of the
419 first instance in <parameter>objects</parameter> is
420 used. <parameter>force-p</parameter> when &t; means that all
421 join slots are updated whereas a value of &nil; means that only
422 unbound join slots are updated. <parameter>max-len</parameter>
423 when non-nil specifies that
424 <function>update-object-joins</function> may issue multiple
425 database queries with a maximum of
426 <parameter>max-len</parameter> instances updated in each query.
430 <title>Examples</title>
436 <title>Side Effects</title>
438 <!-- side effects -->
442 <title>Affected by</title>
450 <title>Exceptional Situations</title>
452 <!-- execeptional situations -->
456 <title>See Also</title>
471 <refentry id="update-record-from-slot">
473 <refname>UPDATE-RECORD-FROM-SLOT</refname>
474 <refpurpose>Updates database from slot value.</refpurpose>
475 <refclass>Function</refclass>
478 <title>Syntax</title>
480 <function>(update-record-from-slot object slot &key database)</function> => <returnvalue><!-- result --></returnvalue></synopsis>
483 <title>Arguments and Values</title>
485 <!-- arguments and values -->
489 <title>Description</title>
490 <para>Updates the value stored in the column represented by the
491 slot, specified by the CLOS slot name
492 <parameter>slot</parameter>, of View Class instance
493 <parameter>object</parameter>. <parameter>database</parameter>
494 specifies the database in which the update is made only if
495 <parameter>object</parameter> is not associated with a
496 database. In this case, a record is created in
497 <parameter>database</parameter> and the attribute represented by
498 <parameter>slot</parameter> is initialised from the value of the
499 supplied slots with other attributes having default
500 values. Furthermore, <parameter>object</parameter> becomes
501 associated with <parameter>database</parameter>.
505 <title>examples</title>
511 <title>side effects</title>
513 modifies sql database.
517 <title>affected by</title>
525 <title>exceptional situations</title>
527 if a database error occurs.
531 <title>see also</title>
546 <refentry id="update-record-from-slots">
548 <refname>update-record-from-slots</refname>
549 <refpurpose>update database from slots of view class object.</refpurpose>
550 <refclass>function</refclass>
553 <title>syntax</title>
555 <function>(update-record-from-slots object slots &key (database *default-database*))</function> => <returnvalue><!-- result --></returnvalue></synopsis>
558 <title>arguments and values</title>
560 <!-- arguments and values -->
564 <title>description</title>
565 <para>updates the values stored in the columns represented by
566 the slots, specified by the clos slot names
567 <parameter>slots</parameter>, of view class instance
568 <parameter>object</parameter>. <parameter>database</parameter>
569 specifies the database in which the update is made only if
570 <parameter>object</parameter> is not associated with a
571 database. In this case, a record is created in the appropriate
572 table of <parameter>database</parameter> and the attributes
573 represented by <parameter>slots</parameter> are initialised from
574 the values of the supplied slots with other attributes having
575 default values. Furthermore, <parameter>object</parameter>
576 becomes associated with <parameter>database</parameter>.
580 <title>Examples</title>
586 <title>Side Effects</title>
588 Modifies the SQL database.
592 <title>Affected by</title>
600 <title>Exceptional Situations</title>
602 <!-- execeptional situations -->
606 <title>See Also</title>
622 <refentry id="update-records-from-instance">
624 <refname>UPDATE-RECORDS-FROM-INSTANCE</refname>
625 <refpurpose>Update database from view class object.</refpurpose>
626 <refclass>Function</refclass>
629 <title>Syntax</title>
631 <function>(update-records-from-instance object &key (database *default-database*))</function> => <returnvalue><!-- result --></returnvalue></synopsis>
634 <title>Arguments and Values</title>
636 <!-- arguments and values -->
640 <title>Description</title>
641 <para>Using an instance of a View Class,
642 <parameter>object</parameter>, update the table that stores its
643 instance data. <parameter>database</parameter> specifies the
644 database in which the update is made only if
645 <parameter>object</parameter> is not associated with a
646 database. In this case, a record is created in the appropriate
647 table of <parameter>database</parameter> using values from the
648 slot values of <parameter>object</parameter>, and
649 <parameter>object</parameter> becomes associated with
650 <parameter>database</parameter>.
654 <title>Examples</title>
660 <title>Side Effects</title>
662 <!-- side effects -->
666 <title>Affected by</title>
674 <title>Exceptional Situations</title>
676 <!-- execeptional situations -->
680 <title>See Also</title>
695 <refentry id="update-slot-from-record">
697 <refname>UPDATE-SLOT-FROM-RECORD</refname>
698 <refpurpose>Update objects slot from database.</refpurpose>
699 <refclass>Function</refclass>
702 <title>Syntax</title>
704 <function>(update-slot-from-record object slot &key (database *default-database*))</function> => <returnvalue><!-- result --></returnvalue></synopsis>
707 <title>Arguments and Values</title>
709 <!-- arguments and values -->
713 <title>Description</title>
714 <para>Updates the slot value, specified by the CLOS slot name
715 <parameter>slot</parameter>, of the View Class instance
716 <parameter>object</parameter> using the attribute values of the
717 appropriate table of <parameter>database</parameter> which
718 defaults to the database associated with
719 <parameter>object</parameter> or, if
720 <parameter>object</parameter> is not associated with a database,
721 <variable>*default-database*</variable>. Join slots are updated
722 but instances of the class on which the join is made are not
727 <title>Examples</title>
733 <title>Side Effects</title>
735 Modifies the slot value of the object.
739 <title>Affected by</title>
742 <member>Data in SQL database.</member>
747 <title>Exceptional Situations</title>
753 <title>See Also</title>