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>
17 <refentry id="db-auto-sync">
19 <refname>*DB-AUTO-SYNC*</refname>
20 <refpurpose>Enables SQL storage during Lisp object creation.</refpurpose>
21 <refclass>Variable</refclass>
24 <title>Value Type</title>
30 <title>Initial Value</title>
34 <title>Description</title>
35 When this variable is &t; an instance is stored in the SQL database when the instance is created
36 by <function>make-instance</function>. When this variable is &nil;, which is the default value, &clsql;
37 behaves like &commonsql;: instances of view classes are stored to the SQL database only when
38 <link linkend="update-record-from-slots"><function>update-record-from-slots</function></link>
42 <title>Examples</title>
44 (let ((instance (make-instance 'foo)))
45 (update-record-from-slots instance))
49 (let ((*db-auto-sync* t))
54 <title>Affected By</title>
58 <title>See Also</title>
60 <member><link linkend="update-record-from-slots"><function>update-record-from-slots</function></link></member>
69 <refentry id="default-update-objects-max-len">
71 <refname>*DEFAULT-UPDATE-OBJECTS-MAX-LEN*</refname>
72 <refpurpose>The default maximum number of objects each query to perform a join</refpurpose>
73 <refclass>Variable</refclass>
76 <title>Value Type</title>
82 <title>Initial Value</title>
86 <title>Description</title>
88 This special variable provides the default value for the
89 <parameter>max-len</parameter> argument of the function <link
90 linkend="update-object-joins"><function>update-object-joins</function></link>.
94 <title>Examples</title>
96 (setq *default-update-objects-max-len* 100)
100 <title>Affected By</title>
104 <title>See Also</title>
113 <refentry id="delete-instance-records">
115 <refname>DELETE-INSTANCE-RECORDS</refname>
116 <refpurpose>Delete SQL records represented by a view class object</refpurpose>
117 <refclass>Function</refclass>
120 <title>Syntax</title>
122 <function>(delete-instance-records object)</function> => <returnvalue><!-- result --></returnvalue></synopsis>
125 <title>Arguments and Values</title>
127 <!-- arguments and values -->
131 <title>Description</title>
132 <para>Deletes the records represented by OBJECT in the
133 appropriate table of the database associated with OBJECT. If
134 OBJECT is not yet associated with a database, an error is
139 <title>Examples</title>
141 * (def-view-class tab () ((a :type integer :db-kind :key) (b :type string)))
142 #<clsql-sys::db-standard-class tab>
143 * (defvar obj (let ((*db-auto-sync* t))
144 (make-instance 'tab :a 5 :b "the string")))
145 * (start-sql-recording :type :both)
146 * (delete-instance-records obj)
152 <title>Side Effects</title>
154 Deletes data from the SQL database.
158 <title>Affected by</title>
160 Permissions granted by the SQL database to the user in the database connection.
164 <title>Exceptional Situations</title>
166 An exception may be signaled if the database connection user does not have
167 sufficient privileges to modify the database.
171 <title>See Also</title>
174 <member><link linkend="update-records"><function>update-records</function></link></member>
175 <member><link linkend="update-records-from-instance"><function>update-records-from-instance</function></link></member>
182 Instances are referenced in the database by values stored in the key slots. If
183 <function>delete-records-from-instance</function> is called with an instance of a class that does
184 not contain any keys, then all records in that table will be deleted.
189 <refentry id="instance-refreshed">
191 <refname>INSTANCE-REFRESHED</refname>
192 <refpurpose>Hook to call on object refresh</refpurpose>
193 <refclass>Generic function</refclass>
196 <title>Syntax</title>
198 <function>(instance-refreshed object)</function> => <returnvalue><!-- result --></returnvalue></synopsis>
201 <title>Arguments and Values</title>
204 <term><parameter>object</parameter></term>
207 The view class object which is being refreshed.
214 <title>Description</title>
215 <para>Provides a hook which is called within an object
216 oriented call to SELECT with a non-nil value of REFRESH when
217 the View Class instance OBJECT has been updated from the
218 database. A method specialised on STANDARD-DB-OBJECT is
219 provided which has no effects. Methods specialised on
220 particular View Classes can be used to specify any operations
221 that need to be made on View Classes instances which have been
222 updated in calls to SELECT.
226 <title>Examples</title>
232 <title>Side Effects</title>
234 <!-- side effects -->
238 <title>Affected by</title>
246 <title>Exceptional Situations</title>
252 <title>See Also</title>
267 <refentry id="update-instance-from-records">
269 <refname>UPDATE-INSTANCE-FROM-RECORDS</refname>
270 <refpurpose>Update slot values from database.</refpurpose>
271 <refclass>Function</refclass>
274 <title>Syntax</title>
276 <function>(update-instance-from-records object &key database)</function> => <returnvalue><!-- result --></returnvalue></synopsis>
279 <title>Arguments and Values</title>
281 <!-- arguments and values -->
285 <title>Description</title>
286 <para>Updates the slot values of the View Class instance
287 OBJECT using the attribute values of the appropriate table of
288 DATABASE which defaults to the database associated with OBJECT
289 or, if OBJECT is not associated with a database,
290 *DEFAULT-DATABASE*. Join slots are updated but instances of
291 the class on which the join is made are not updated.
295 <title>Examples</title>
301 <title>Side Effects</title>
303 <!-- side effects -->
307 <title>Affected by</title>
315 <title>Exceptional Situations</title>
317 <!-- execeptional situations -->
321 <title>See Also</title>
336 <refentry id="update-objects-joins">
338 <refname>UPDATE-OBJECTS-JOINS</refname>
339 <refpurpose>Updates joined slots of objects</refpurpose>
340 <refclass>Function</refclass>
343 <title>Syntax</title>
345 <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>
348 <title>Arguments and Values</title>
350 <!-- arguments and values -->
354 <title>Description</title>
355 <para>Updates from the records of the appropriate
356 database tables the join slots specified by SLOTS in
357 the supplied list of View Class instances OBJECTS.
358 SLOTS is t by default which means that all join slots
359 with :retrieval :immediate are updated. CLASS-NAME is
360 used to specify the View Class of all instance in
361 OBJECTS and default to nil which means that the class
362 of the first instance in OBJECTS is used. FORCE-P is t
363 by default which means that all join slots are updated
364 whereas a value of nil means that only unbound join
365 slots are updated. MAX-LEN defaults to
366 *DEFAULT-UPDATE-OBJECTS-MAX-LEN* and when non-nil
367 specifies that UPDATE-OBJECT-JOINS may issue multiple
368 database queries with a maximum of MAX-LEN instances
369 updated in each query.
373 <title>Examples</title>
379 <title>Side Effects</title>
381 <!-- side effects -->
385 <title>Affected by</title>
393 <title>Exceptional Situations</title>
395 <!-- execeptional situations -->
399 <title>See Also</title>
414 <refentry id="update-record-from-slot">
416 <refname>UPDATE-RECORD-FROM-SLOT</refname>
417 <refpurpose>Updates database from slot value</refpurpose>
418 <refclass>Function</refclass>
421 <title>Syntax</title>
423 <function>(update-record-from-slot object slot &key database)</function> => <returnvalue><!-- result --></returnvalue></synopsis>
426 <title>Arguments and Values</title>
428 <!-- arguments and values -->
432 <title>Description</title>
433 <para>Updates the value stored in the column represented by
434 the slot, specified by the CLOS slot name SLOT, of View Class
435 instance OBJECT. DATABASE defaults to *DEFAULT-DATABASE* and
436 specifies the database in which the update is made only if
437 OBJECT is not associated with a database. In this case, a
438 record is created in DATABASE and the attribute represented by
439 SLOT is initialised from the value of the supplied slots with
440 other attributes having default values. Furthermore, OBJECT
441 becomes associated with DATABASE.
445 <title>Examples</title>
451 <title>Side Effects</title>
453 <!-- side effects -->
457 <title>Affected by</title>
465 <title>Exceptional Situations</title>
467 <!-- execeptional situations -->
471 <title>See Also</title>
486 <refentry id="update-record-from-slots">
488 <refname>UPDATE-RECORD-FROM-SLOTS</refname>
489 <refpurpose>Update database from slots of view class object</refpurpose>
490 <refclass>Function</refclass>
493 <title>Syntax</title>
495 <function>(update-record-from-slots object slots &key database)</function> => <returnvalue><!-- result --></returnvalue></synopsis>
498 <title>Arguments and Values</title>
500 <!-- arguments and values -->
504 <title>Description</title>
505 <para>Updates the values stored in the columns represented by
506 the slots, specified by the CLOS slot names SLOTS, of View
507 Class instance OBJECT. DATABASE defaults to *DEFAULT-DATABASE*
508 and specifies the database in which the update is made only if
509 OBJECT is not associated with a database. In this case, a
510 record is created in the appropriate table of DATABASE and the
511 attributes represented by SLOTS are initialised from the
512 values of the supplied slots with other attributes having
513 default values. Furthermore, OBJECT becomes associated with
518 <title>Examples</title>
524 <title>Side Effects</title>
526 <!-- side effects -->
530 <title>Affected by</title>
538 <title>Exceptional Situations</title>
540 <!-- execeptional situations -->
544 <title>See Also</title>
560 <refentry id="update-records-from-instance">
562 <refname>UPDATE-RECORDS-FROM-INSTANCE</refname>
563 <refpurpose>Update database from view class object.</refpurpose>
564 <refclass>Function</refclass>
567 <title>Syntax</title>
569 <function>(update-records-from-instance object &key database)</function> => <returnvalue><!-- result --></returnvalue></synopsis>
572 <title>Arguments and Values</title>
574 <!-- arguments and values -->
578 <title>Description</title>
579 <para>Using an instance of a View Class, OBJECT, update the
580 table that stores its instance data. DATABASE defaults to
581 *DEFAULT-DATABASE* and specifies the database in which the
582 update is made only if OBJECT is not associated with a
583 database. In this case, a record is created in the appropriate
584 table of DATABASE using values from the slot values of OBJECT,
585 and OBJECT becomes associated with DATABASE.
589 <title>Examples</title>
595 <title>Side Effects</title>
597 <!-- side effects -->
601 <title>Affected by</title>
609 <title>Exceptional Situations</title>
611 <!-- execeptional situations -->
615 <title>See Also</title>
630 <refentry id="update-slot-from-record">
632 <refname>UPDATE-SLOT-FROM-RECORD</refname>
633 <refpurpose>Update objects slot from database.</refpurpose>
634 <refclass>Function</refclass>
637 <title>Syntax</title>
639 <function>(update-slot-from-record object slot &key database)</function> => <returnvalue><!-- result --></returnvalue></synopsis>
642 <title>Arguments and Values</title>
644 <!-- arguments and values -->
648 <title>Description</title>
649 <para>Updates the slot value, specified by the CLOS slot name
650 SLOT, of the View Class instance OBJECT using the attribute
651 values of the appropriate table of DATABASE which defaults to
652 the database associated with OBJECT or, if OBJECT is not
653 associated with a database, *DEFAULT-DATABASE*. Join slots
654 are updated but instances of the class on which the join is
655 made are not updated.
659 <title>Examples</title>
665 <title>Side Effects</title>
667 <!-- side effects -->
671 <title>Affected by</title>
679 <title>Exceptional Situations</title>
681 <!-- execeptional situations -->
685 <title>See Also</title>