summaryrefslogtreecommitdiff
path: root/doc/ref-oodml.xml
blob: 8a3423557fed74a5162c78cc8cdbccd7db1d6d41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
<?xml version='1.0' ?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
<!ENTITY % myents SYSTEM "entities.inc">
%myents;
]>

<!-- Object Oriented Data Manipulation Language --> 
<reference id="ref-oodml"> 
  <title>Object Oriented Data Manipulation Language (OODML)</title> 
    <partintro>
    <para>
      Object Oriented Data Manipulation Language (OODML) provides a
      Common Lisp Object System (CLOS) interface to SQL
      databases. View classes are defined with the <link
      linkend="ref-ooddl">OODDL</link> interface and objects are read
      and written with the OODML.
    </para>
    <para>
      The main function for reading data with the OODML is the <link
      linkend="select"><function>select</function></link>
      function. The <function>select</function> is also used in the
      FDML. However, when <function>select</function> is given a view
      class name, it returns a list of instances of view classes.
    </para>
    <para>
      View class instances can be updated to reflect any changes in
      the database with the functions <link
      linkend="update-slot-from-record"><function>update-slot-from-record</function></link>
      and <link
      linkend="update-instance-from-records"><function>update-instance-from-records</function></link>.
    </para>
    <para>To update the database to reflect changes made to instances of view classes, use the functions <link
      linkend="update-records-from-instance"><function>update-records-from-instance</function></link>,
      <link
      linkend="update-record-from-slot"><function>update-record-from-slot</function></link>, and
      <link
      linkend="update-record-from-slots"><function>update-record-from-slots</function></link>.
    </para>
    <para>
      The function <link
      linkend="delete-instance-records"><function>delete-instance-records</function></link>
      deletes the records corresponding to an instance of a view
      class.
    </para>
  </partintro>

  <refentry id="db-auto-sync">
    <refnamediv>
      <refname>*DB-AUTO-SYNC*</refname>
      <refpurpose>Enables SQL storage during Lisp object creation.</refpurpose>
      <refclass>Variable</refclass>
    </refnamediv>
    <refsect1>
      <title>Value Type</title>
      <para>
	Boolean
      </para> 
    </refsect1>
    <refsect1>
      <title>Initial Value</title>
      <para>&nil;</para>
    </refsect1>
    <refsect1>
      <title>Description</title> 
      <para>
	When this variable is &t; an instance is stored in the SQL
	database when the instance is created by
	<function>make-instance</function>. Furthermore, the
	appropriate database records are updated whenever the slots of
	a <glossterm linkend="gloss-view-class">View Class</glossterm>
	instance are modified.
      </para> 
      <para> 
        When this variable is &nil;, which is the default value,
        &clsql; behaves like &commonsql;: instances of view classes
        are stored or updated in the SQL database only when <link
        linkend="update-records-from-instance"><function>update-record-from-instance</function></link>,
        <link
        linkend="update-record-from-slot"><function>update-record-from-slot</function></link>
        or <link
        linkend="update-record-from-slots"><function>update-record-from-slots</function></link>
        are called.
      </para>
    </refsect1>
    <refsect1>
      <title>Examples</title>
      <screen>
	(let ((instance (make-instance 'foo)))
	  (update-records-from-instance instance))

	;; is equivalent to

	(let ((*db-auto-sync* t))
	  (make-instance 'foo))
          
        ;; and 

        (progn 
          (setf (slot-value instance 'bar) "baz")
          (update-record-from-slot instance 'bar))

        ;; is equivalent to 

        (let ((*db-auto-sync* t))
          (setf (slot-value instance 'bar) "baz"))
      </screen>
    </refsect1>
    <refsect1>
      <title>Affected By</title>
      <para>None.</para>
    </refsect1>
    <refsect1>
      <title>See Also</title>
      <simplelist>
        <member><link linkend="update-records-from-instance"><function>update-records-from-instance</function></link></member>
        <member><link linkend="update-record-from-slot"><function>update-record-from-slot</function></link></member>
        <member><link linkend="update-record-from-slots"><function>update-record-from-slots</function></link></member>
      </simplelist>
    </refsect1>
    <refsect1>
      <title>Notes</title>
      <para>This is a CLSQL extension to the CommonSQL API.</para>
    </refsect1>
  </refentry>

  <refentry id="default-caching">
    <refnamediv>
      <refname>*DEFAULT-CACHING*</refname>
      <refpurpose>Controls the default caching behavior.</refpurpose>
      <refclass>Variable</refclass>
    </refnamediv>
    <refsect1>
      <title>Value Type</title>
      <para>
	Boolean
      </para> 
    </refsect1>
    <refsect1>
      <title>Initial Value</title>
      <para>&t;</para>
    </refsect1>
    <refsect1>
      <title>Description</title> 
      <para>
	This variable stores the default value of the
	<varname>CACHING</varname> keyword for the <link
	linkend="select"><function>select</function></link>.
      </para> 
    </refsect1>
    <refsect1>
      <title>Examples</title>
      <screen>
	(let ((*default-caching* nil)))
	  (select 'foo))

	;; is equivalent to

	(select 'foo :caching nil)
      </screen>
    </refsect1>
    <refsect1>
      <title>Affected By</title>
      <para>None.</para>
    </refsect1>
    <refsect1>
      <title>See Also</title>
      <simplelist>
        <member><link linkend="select"><function>select</function></link></member>
      </simplelist>
    </refsect1>
    <refsect1>
      <title>Notes</title> <para>This is a CLSQL extension to the
      &commonsql; API. &commonsql; has caching on at all times.</para>
    </refsect1>
  </refentry>

  <refentry id="default-update-objects-max-len">
    <refnamediv>
      <refname>*DEFAULT-UPDATE-OBJECTS-MAX-LEN*</refname>
      <refpurpose>The default maximum number of objects each query to perform a join</refpurpose>
      <refclass>Variable</refclass>
    </refnamediv>
    <refsect1>
      <title>Value Type</title>
      <para>
	(or null integer)
      </para> 
    </refsect1>
    <refsect1>
      <title>Initial Value</title>
      <para>&nil;</para>
    </refsect1>
    <refsect1>
      <title>Description</title>
      <para>
	This special variable provides the default value for the
	<parameter>max-len</parameter> argument of the function <link
	linkend="update-objects-joins"><function>update-object-joins</function></link>.
      </para>
    </refsect1>
    <refsect1>
      <title>Examples</title>
      <screen>
	(setq *default-update-objects-max-len* 100)
      </screen>
    </refsect1>
    <refsect1>
      <title>Affected By</title>
      <para>None.</para>
    </refsect1>
    <refsect1>
      <title>See Also</title>
      <simplelist>
	<member><link linkend="update-objects-joins"><function>update-object-joins</function></link></member>
      </simplelist>
    </refsect1>
    <refsect1>
      <title>Notes</title>
      <para>None.</para>
    </refsect1>
  </refentry>

  <refentry id="instance-refreshed">
    <refnamediv>
      <refname>INSTANCE-REFRESHED</refname>
      <refpurpose>User hook to call on object refresh.</refpurpose>
      <refclass>Generic function</refclass>
    </refnamediv>
    <refsect1>
      <title>Syntax</title>
      <synopsis>
      <function>instance-refreshed</function> <replaceable>object</replaceable> => <returnvalue><!-- no result --></returnvalue></synopsis>
    </refsect1>
    <refsect1>
      <title>Arguments and Values</title>
      <variablelist>
        <varlistentry>
          <term><parameter>object</parameter></term>
          <listitem>
            <para>
	      The <glossterm linkend="gloss-view-class">View Class</glossterm> object which is being refreshed.
            </para>
          </listitem>
        </varlistentry>
      </variablelist>
    </refsect1>
    <refsect1>
      <title>Description</title>
      <para>Provides a hook which is called within an object oriented
      call to <function>select</function> with a non-nil value of
      <parameter>refresh</parameter> when the <glossterm
      linkend="gloss-view-class">View Class</glossterm> instance
      <parameter>object</parameter> has been updated from the
      database. A method specialised on
      <type>standard-db-object</type> is provided which has no
      effects. Methods specialised on particular View Classes can be
      used to specify any operations that need to be made on View
      Classes instances which have been updated in calls to
      <function>select</function>.
      </para>
    </refsect1>
    <refsect1>
      <title>Examples</title>
      <screen>
(slot-value employee1 'email)
=> "lenin@soviet.org"
(defmethod instance-refreshed ((e employee))
   (format t "~&amp;Details for ~A ~A have been updated from the database."
           (slot-value e 'first-name)
           (slot-value e 'last-name)))
=> #&lt;Standard-Method INSTANCE-REFRESHED (EMPLOYEE) {48174D9D}>
(select 'employee :where [= [slot-value 'employee 'emplid] 1] :flatp t)
=> (#&lt;EMPLOYEE {48149995}>)
(slot-value (car *) 'email)
=> "lenin@soviet.org"
(update-records [employee] :av-pairs '(([email] "v.lenin@soviet.org")) 
                :where [= [emplid] 1])
=> 
(select 'employee :where [= [slot-value 'employee 'emplid] 1] :flatp t)
=> (#&lt;EMPLOYEE {48149995}>)
(slot-value (car *) 'email)
=> "lenin@soviet.org"
(select 'employee :where [= [slot-value 'employee 'emplid] 1] :flatp t :refresh t)
Details for Vladimir Lenin have been updated from the database.
=> (#&lt;EMPLOYEE {48149995}>)
(slot-value (car *) 'email)
=> "v.lenin@soviet.org"
      </screen>
    </refsect1>
    <refsect1>
      <title>Side Effects</title>
      <para>
        The user hook function may cause side effects.
      </para>
    </refsect1>
    <refsect1>
      <title>Exceptional Situations</title>
      <para>
	None.
      </para>
    </refsect1>
    <refsect1>
      <title>See Also</title>
      <para>
        <simplelist>
          <member><link linkend="select"><function>select</function></link></member>
        </simplelist>
      </para>
    </refsect1>
    <refsect1>
      <title>Notes</title>
      <para>
        None. 
      </para>
    </refsect1>
  </refentry> 

  <refentry id="delete-instance-records">
    <refnamediv>
      <refname>DELETE-INSTANCE-RECORDS</refname>
      <refpurpose>Delete SQL records represented by a <glossterm linkend="gloss-view-class">View Class</glossterm>
      object.</refpurpose>
      <refclass>Function</refclass>
    </refnamediv>
    <refsect1>
      <title>Syntax</title>
      <synopsis>
      <function>delete-instance-records</function> <replaceable>object</replaceable> => <returnvalue><!-- no result --></returnvalue></synopsis>
    </refsect1>
    <refsect1>
      <title>Arguments and Values</title>
      <variablelist>
	<varlistentry>
	  <term><parameter>object</parameter></term>
	  <listitem>
	    <para>
	      An instance of a <glossterm linkend="gloss-view-class">View
	      Class</glossterm>.
	    </para>
	  </listitem>
	</varlistentry>
      </variablelist>
    </refsect1>
    <refsect1>
      <title>Description</title>
      <para>Deletes the records represented by
      <parameter>object</parameter> in the appropriate table of the
      database associated with <parameter>object</parameter>. If
      <parameter>object</parameter> is not yet associated with a
      database, an error is signalled.
      </para>
    </refsect1>
    <refsect1>
      <title>Examples</title>
      <screen>
(def-view-class tab () 
  ((a :initarg :a :type integer :db-kind :key) 
   (b :initarg :b :type string)))
=> #&lt;Standard-Db-Class TAB {49B01845}>
(create-view-from-class 'tab)
=> 
(defvar obj (let ((*db-auto-sync* t))
              (make-instance 'tab :a 5 :b "the string")))
=> OBJ
(start-sql-recording :type :both)
=> 
(delete-instance-records obj) 
;; 2004-07-17 11:07:19 foo/bar/baz => DELETE FROM tab WHERE tab.a = 5
;; 2004-07-17 11:07:19 foo/bar/baz &lt;= T
=> 
      </screen>
    </refsect1>
    <refsect1>
      <title>Side Effects</title>
      <para>
	Deletes data from the SQL database.
      </para>
    </refsect1>
    <refsect1>
      <title>Affected by</title>
      <para>
	Permissions granted by the SQL database to the user in the
	database connection.
      </para>
    </refsect1>
    <refsect1>
      <title>Exceptional Situations</title>
      <para>
	An exception may be signaled if the database connection user
	does not have sufficient privileges to modify the database. An
	error of type <type>sql-database-error</type> is signalled if
	<replaceable>object</replaceable> is not associated with an
	active database.
      </para>
    </refsect1>
    <refsect1>
      <title>See Also</title>
      <simplelist>
        <member><link linkend="update-records"><function>update-records</function></link></member>
        <member><link linkend="delete-records"><function>delete-records</function></link></member>
        <member><link linkend="update-records-from-instance"><function>update-records-from-instance</function></link></member>
      </simplelist>
    </refsect1>
    <refsect1>
      <title>Notes</title>
      <para>
	Instances are referenced in the database by values stored in
	the key slots. If
	<function>delete-records-from-instance</function> is called
	with an instance of a class that does not contain any keys,
	then all records in that table will be deleted.
      </para>
    </refsect1>
  </refentry> 

  <refentry id="update-records-from-instance">
    <refnamediv>
      <refname>UPDATE-RECORDS-FROM-INSTANCE</refname>
      <refpurpose>Update database from view class object.</refpurpose>
      <refclass>Function</refclass>
    </refnamediv>
    <refsect1>
      <title>Syntax</title>
      <synopsis>
      <function>update-records-from-instance</function> <replaceable>object</replaceable> &amp;key <replaceable>database</replaceable> => <returnvalue><!-- no result --></returnvalue></synopsis>
    </refsect1>
    <refsect1>
      <title>Arguments and Values</title>
      <variablelist>
	<varlistentry>
	  <term><parameter>object</parameter></term>
	  <listitem>
	    <para>
	      An instance of a <glossterm linkend="gloss-view-class">View
	      Class</glossterm>.
	    </para>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter>database</parameter></term>
	  <listitem>
	    <para>
              <glossterm linkend="gloss-database-object">database
              object</glossterm>. This will default to the value of
              <symbol>*default-database*</symbol>.
	    </para>
	  </listitem>
	</varlistentry>
      </variablelist>
    </refsect1>
    <refsect1>
      <title>Description</title>
      <para>Using an instance of a <glossterm
      linkend="gloss-view-class">View Class</glossterm>,
      <parameter>object</parameter>, update the table that stores its
      instance data. <parameter>database</parameter> specifies the
      database in which the update is made only if
      <parameter>object</parameter> is not associated with a
      database. In this case, a record is created in the appropriate
      table of <parameter>database</parameter> using values from the
      slot values of <parameter>object</parameter>, and
      <parameter>object</parameter> becomes associated with
      <parameter>database</parameter>.
      </para>
    </refsect1>
    <refsect1>
      <title>Examples</title>
      <screen>
(select [email] :from [employee] :where [= [emplid] 1] :field-names nil :flatp t)
=> ("lenin@soviet.org")
(defvar *e1* (car (select 'employee :where [= [slot-value 'employee 'emplid] 1] :flatp t)))
=> *E1* 
(slot-value *e1* 'email)
=> "lenin@soviet.org"
(setf (slot-value *e1* 'email) "v.lenin@soviet.org")
=> "v.lenin@soviet.org"
(update-records-from-instance *e1*)
=> 
(select [email] :from [employee] :where [= [emplid] 1] :field-names nil :flatp t)
=> ("v.lenin@soviet.org")
     </screen>
    </refsect1>
    <refsect1>
      <title>Side Effects</title>
      <para>
	Modifies the database.
      </para>
    </refsect1>
    <refsect1>
      <title>Affected by</title>
      <para>
	Nothing.
      </para>
    </refsect1>
    <refsect1>
      <title>Exceptional Situations</title>
      <para>
	Database errors.
      </para>
    </refsect1>
    <refsect1>
      <title>See Also</title>
      <simplelist>
        <member><link linkend="update-record-from-slot"><function>update-record-from-slot</function></link></member>
        <member><link linkend="update-record-from-slots"><function>update-record-from-slots</function></link></member>
        <member><link linkend="update-records"><function>update-records</function></link></member>
      </simplelist>
    </refsect1>
    <refsect1>
      <title>Notes</title>
      <para>
        None. 
      </para>
    </refsect1>
  </refentry> 

  <refentry id="update-record-from-slot">
    <refnamediv>
      <refname>UPDATE-RECORD-FROM-SLOT</refname>
      <refpurpose>Updates database from slot value.</refpurpose>
      <refclass>Function</refclass>
    </refnamediv>
    <refsect1>
      <title>Syntax</title>
      <synopsis>
      <function>update-record-from-slot</function> <replaceable>object</replaceable> <replaceable>slot</replaceable> &amp;key <replaceable>database</replaceable> => <returnvalue><!-- no result --></returnvalue></synopsis>
    </refsect1>
    <refsect1>
      <title>Arguments and Values</title>
      <variablelist>
	<varlistentry>
	  <term><parameter>object</parameter></term>
	  <listitem>
	    <para>
	      An instance of a <glossterm linkend="gloss-view-class">View Class</glossterm>.
	    </para>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter>slot</parameter></term>
	  <listitem>
	    <para>
	      The name of a slot in <parameter>object</parameter>.
	    </para>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter>database</parameter></term>
	  <listitem>
	    <para>
              A <glossterm linkend="gloss-database-object">database
              object</glossterm>. This will default to the value of
              <symbol>*default-database*</symbol>.
	    </para>
	  </listitem>
	</varlistentry>
      </variablelist>
    </refsect1>
    <refsect1>
      <title>Description</title>
      <para>Updates the value stored in the column represented by the
      slot, specified by the CLOS slot name
      <parameter>slot</parameter>, of <glossterm linkend="gloss-view-class">View Class</glossterm> instance
      <parameter>object</parameter>. <parameter>database</parameter>
      specifies the database in which the update is made only if
      <parameter>object</parameter> is not associated with a
      database. In this case, a record is created in
      <parameter>database</parameter> and the attribute represented by
      <parameter>slot</parameter> is initialised from the value of the
      supplied slots with other attributes having default
      values. Furthermore, <parameter>object</parameter> becomes
      associated with <parameter>database</parameter>.
      </para>
    </refsect1>
    <refsect1>
      <title>Examples</title>
      <screen>
(select [email] :from [employee] :where [= [emplid] 1] :field-names nil :flatp t)
=> ("lenin@soviet.org")
(defvar *e1* (car (select 'employee :where [= [slot-value 'employee 'emplid] 1] :flatp t)))
=> *E1* 
(slot-value *e1* 'email)
=> "lenin@soviet.org"
(setf (slot-value *e1* 'email) "v.lenin@soviet.org")
=> "v.lenin@soviet.org"
(update-record-from-slot *e1* 'email)
=> 
(select [email] :from [employee] :where [= [emplid] 1] :field-names nil :flatp t)
=> ("v.lenin@soviet.org")
      </screen>
    </refsect1>
    <refsect1>
      <title>Side Effects</title>
      <para>
	Modifies database.
      </para>
    </refsect1>
    <refsect1>
      <title>Affected By</title>
      <para>
	Nothing.
      </para>
    </refsect1>
    <refsect1>
      <title>Exceptional Situations</title>
      <para>
	Database errors.
      </para>
    </refsect1>
    <refsect1>
      <title>See Also</title>
      <simplelist>
        <member><link linkend="update-record-from-slots"><function>update-record-from-slots</function></link></member>
        <member><link linkend="update-records-from-instance"><function>update-records-from-instance</function></link></member>
      </simplelist>
    </refsect1>
    <refsect1>
      <title>Notes</title>
      <para>
        None. 
      </para>
    </refsect1>
  </refentry> 

  <refentry id="update-record-from-slots">
    <refnamediv>
      <refname>UPDATE-RECORD-FROM-SLOTS</refname>
      <refpurpose>Update database from slots of view class object.</refpurpose>
      <refclass>function</refclass>
    </refnamediv>
    <refsect1>
      <title>syntax</title>
      <synopsis>
      <function>update-record-from-slots</function> <replaceable>object</replaceable> <replaceable>slots</replaceable> &amp;key <replaceable>database</replaceable> => <returnvalue><!-- no result --></returnvalue></synopsis>
    </refsect1>
    <refsect1>
      <title>Arguments and Values</title>
      <variablelist>
	<varlistentry>
	  <term><parameter>object</parameter></term>
	  <listitem>
	    <para>
	      An instance of a <glossterm linkend="gloss-view-class">View Class</glossterm>.
	    </para>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter>slots</parameter></term>
	  <listitem>
	    <para>
	      A list of slot names in <parameter>object</parameter>.
	    </para>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter>database</parameter></term>
	  <listitem>
	    <para>
              A <glossterm linkend="gloss-database-object">database
              object</glossterm>. This will default to the value of
              <symbol>*default-database*</symbol>.
	    </para>
	  </listitem>
	</varlistentry>
      </variablelist>
    </refsect1>
    <refsect1>
      <title>Description</title>
      <para>Updates the values stored in the columns represented by
      the slots, specified by the clos slot names
      <parameter>slots</parameter>, of <glossterm linkend="gloss-view-class">View Class</glossterm> instance
      <parameter>object</parameter>. <parameter>database</parameter>
      specifies the database in which the update is made only if
      <parameter>object</parameter> is not associated with a
      database. In this case, a record is created in the appropriate
      table of <parameter>database</parameter> and the attributes
      represented by <parameter>slots</parameter> are initialised from
      the values of the supplied slots with other attributes having
      default values. Furthermore, <parameter>object</parameter>
      becomes associated with <parameter>database</parameter>.
      </para>
    </refsect1>
    <refsect1>
      <title>Examples</title>
      <screen>
(select [last-name] [email] :from [employee] :where [= [emplid] 1] :field-names nil)
=> (("Lenin" "lenin@soviet.org"))
(defvar *e1* (car (select 'employee :where [= [slot-value 'employee 'emplid] 1] :flatp t)))
=> *E1* 
(slot-value *e1* 'last-name)
=> "Lenin"
(slot-value *e1* 'email)
=> "lenin@soviet.org"
(setf (slot-value *e1* 'last-name) "Ivanovich")
=> "Ivanovich"
(setf (slot-value *e1* 'email) "v.ivanovich@soviet.org")
=> "v.ivanovich@soviet.org"
(update-record-from-slots *e1* '(email last-name))
=> 
(select [last-name] [email] :from [employee] :where [= [emplid] 1] :field-names nil)
=> (("Ivanovich" "v.ivanovich@soviet.org"))
      </screen>
    </refsect1>
    <refsect1>
      <title>Side Effects</title>
      <para>
	Modifies the SQL database.
      </para>
    </refsect1>
    <refsect1>
      <title>Affected by</title>
      <para>
	Nothing.
      </para>
    </refsect1>
    <refsect1>
      <title>Exceptional Situations</title>
      <para>
	Database errors.
      </para>
    </refsect1>
    <refsect1>
      <title>See Also</title>
      <para>
        <simplelist>
	  <member><link linkend="update-record-from-slot"><function>update-record-from-slot</function></link></member>
	  <member><link linkend="update-records-from-instance"><function>update-records-from-instance</function></link></member>
        </simplelist>
      </para>
    </refsect1>
    <refsect1>
      <title>Notes</title>
      <para>
        None. 
      </para>
    </refsect1>
  </refentry> 

  <refentry id="update-instance-from-records">
    <refnamediv>
      <refname>UPDATE-INSTANCE-FROM-RECORDS</refname>
      <refpurpose>Update slot values from database.</refpurpose>
      <refclass>Function</refclass>
    </refnamediv>
    <refsect1>
      <title>Syntax</title>
      <synopsis>
      <function>update-instance-from-records</function> <replaceable>object</replaceable> &amp;key <replaceable>database</replaceable> => <returnvalue>object</returnvalue></synopsis>
    </refsect1>
    <refsect1>
      <title>Arguments and Values</title>
      <variablelist>
	<varlistentry>
	  <term><parameter>object</parameter></term>
	  <listitem>
	    <para>
	      An instance of a <glossterm linkend="gloss-view-class">View Class</glossterm>.
	    </para>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter>database</parameter></term>
	  <listitem>
	    <para>
              A <glossterm linkend="gloss-database-object">database
              object</glossterm>. This will default to the value of
              <symbol>*default-database*</symbol>.
	    </para>
	  </listitem>
	</varlistentry>
      </variablelist>
    </refsect1>
    <refsect1>
      <title>Description</title>
      <para>Updates the slot values of the <glossterm
      linkend="gloss-view-class">View Class</glossterm> instance
      <parameter>object</parameter> using the attribute values of the
      appropriate table of <parameter>database</parameter> which
      defaults to the database associated with
      <parameter>object</parameter> or, if
      <parameter>object</parameter> is not associated with a database,
      <varname>*default-database*</varname>.  Join slots are updated
      but instances of the class on which the join is made are not
      updated.
      </para>
    </refsect1>
    <refsect1>
      <title>Examples</title>
      <screen>
(defvar *e1* (car (select 'employee :where [= [slot-value 'employee 'emplid] 1] :flatp t)))
=> *E1* 
(slot-value *e1* 'email)
=> "lenin@soviet.org"
(update-records [employee] 
                :av-pairs '(([email] "v.lenin@soviet.org"))
                :where [= [emplid] 1])
=> 
(update-instance-from-records *e1*)
=> #&lt;EMPLOYEE {4806B53D}>
(slot-value *e1* 'email)
=> "v.lenin@soviet.org"
      </screen>
    </refsect1>
    <refsect1>
      <title>Side Effects</title>
      <para>
        Slot values of <parameter>object</parameter> may be modified.
      </para>
    </refsect1>
    <refsect1>
      <title>Affected by</title>
      <para>
        <simplelist>
	  <member>Data in SQL database.</member>
        </simplelist>
      </para>
    </refsect1>
    <refsect1>
      <title>Exceptional Situations</title>
      <para>
        If <parameter>database</parameter> is not able to be read.
      </para>
    </refsect1>
    <refsect1>
      <title>See Also</title>
      <simplelist>
        <member><link linkend="update-slot-from-record"><function>update-slot-from-record</function></link></member>
        <member><link linkend="update-objects-joins"><function>update-objects-joins</function></link></member>
      </simplelist>
    </refsect1>
    <refsect1>
      <title>Notes</title>
      <para>
        None. 
      </para>
    </refsect1>
  </refentry> 

  <refentry id="update-slot-from-record">
    <refnamediv>
      <refname>UPDATE-SLOT-FROM-RECORD</refname>
      <refpurpose>Update objects slot from database.</refpurpose>
      <refclass>Function</refclass>
    </refnamediv>
    <refsect1>
      <title>Syntax</title>
      <synopsis>
      <function>update-slot-from-record</function> <replaceable>object</replaceable> <replaceable>slot</replaceable> &amp;key <replaceable>database</replaceable> => <returnvalue>object</returnvalue></synopsis>
    </refsect1>
    <refsect1>
      <title>Arguments and Values</title>
      <variablelist>
	<varlistentry>
	  <term><parameter>object</parameter></term>
	  <listitem>
	    <para>
	      An instance of a <glossterm linkend="gloss-view-class">View Class</glossterm>.
	    </para>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter>slot</parameter></term>
	  <listitem>
	    <para>
	      The name of a slot in <parameter>object</parameter>.
	    </para>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter>database</parameter></term>
	  <listitem>
	    <para>
              A <glossterm linkend="gloss-database-object">database
              object</glossterm>. This will default to the value of
              <symbol>*default-database*</symbol>.
	    </para>
	  </listitem>
	</varlistentry>
      </variablelist>
    </refsect1>
    <refsect1>
      <title>Description</title>
      <para>Updates the slot value, specified by the CLOS slot name
      <parameter>slot</parameter>, of the <glossterm
      linkend="gloss-view-class">View Class</glossterm> instance
      <parameter>object</parameter> using the attribute values of the
      appropriate table of <parameter>database</parameter> which
      defaults to the database associated with
      <parameter>object</parameter> or, if
      <parameter>object</parameter> is not associated with a database,
      <varname>*default-database*</varname>.  Join slots are updated
      but instances of the class on which the join is made are not
      updated.
      </para>
    </refsect1>
    <refsect1>
      <title>Examples</title>
      <screen>
(defvar *e1* (car (select 'employee :where [= [slot-value 'employee 'emplid] 1] :flatp t)))
=> *E1* 
(slot-value *e1* 'email)
=> "lenin@soviet.org"
(update-records [employee] 
                :av-pairs '(([email] "v.lenin@soviet.org"))
                :where [= [emplid] 1])
=> 
(update-slot-from-record *e1* 'email)
=> #&lt;EMPLOYEE {4806B53D}>
(slot-value *e1* 'email)
=> "v.lenin@soviet.org"
      </screen>
    </refsect1>
    <refsect1>
      <title>Side Effects</title>
      <para>
	Modifies the slot value of the object.
      </para>
    </refsect1>
    <refsect1>
      <title>Affected by</title>
      <para>
        <simplelist>
	  <member>Data in SQL database.</member>
        </simplelist>
      </para>
    </refsect1>
    <refsect1>
      <title>Exceptional Situations</title>
      <para>
	Database errors.
      </para>
    </refsect1>
    <refsect1>
      <title>See Also</title>
      <simplelist>
        <member><link linkend="update-instance-from-records"><function>update-instance-from-records</function></link></member>
        <member><link linkend="update-objects-joins"><function>update-objects-joins</function></link></member>
      </simplelist>
    </refsect1>
    <refsect1>
      <title>Notes</title>
      <para>
        None. 
      </para>
    </refsect1>
  </refentry> 

  <refentry id="update-objects-joins">
    <refnamediv>
      <refname>UPDATE-OBJECTS-JOINS</refname>
      <refpurpose>Updates joined slots of objects.</refpurpose>
      <refclass>Function</refclass>
    </refnamediv>
    <refsect1>
      <title>Syntax</title>
      <synopsis>
      <function>update-objects-joins</function> <replaceable>objects</replaceable> &amp;key <replaceable>slots</replaceable> <replaceable>force-p</replaceable> <replaceable>class-name</replaceable> <replaceable>max-len</replaceable> => <returnvalue><!-- no result --></returnvalue></synopsis>
    </refsect1>
    <refsect1>
      <title>Arguments and Values</title>
      <variablelist>
	<varlistentry>
	  <term><parameter>objects</parameter></term>
	  <listitem>
	    <para>
	      A list of instances of a <glossterm
	      linkend="gloss-view-class">View Class</glossterm>.
	    </para>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter>slots</parameter></term>
	  <listitem>
	    <para>* :immediate (default) - refresh join slots with :retrieval :immediate</para>
            <para>* :deferred - refresh join slots created with :retrieval :deferred</para>
            <para>* :all,t - refresh all join slots regardless of :retrieval</para>
            <para>* list of symbols - which explicit slots to refresh</para>
            <para>* a single symobl - what slot to refresh</para>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter>force-p</parameter></term>
	  <listitem>
	    <para>
              A Boolean, defaulting to &t;. 
	    </para>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter>class-name</parameter></term>
	  <listitem>
	    <para>
	      A list of instances of a <glossterm
	      linkend="gloss-view-class">View Class</glossterm>.
	    </para>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter>max-len</parameter></term>
	  <listitem>
	    <para>
              A non-negative integer or &nil; defaulting to
              <symbol>*default-update-objects-max-len*</symbol>.
              When non-nil this is essentially a batch size for the max number of objects
              to query from the database at a time.  If we need more than max-len
              we loop till we have all the objects
	    </para>
	  </listitem>
	</varlistentry>
      </variablelist>
    </refsect1>
    <refsect1>
      <title>Description</title>
      <para>
        Updates from the records of the appropriate database tables the join slots
        specified by SLOTS in the supplied list of 
        <glossterm linkend="gloss-view-class">View Class</glossterm> instances OBJECTS.
        
        A simpler method of causing a join-slot to be requeried is to set it to
        unbound, then request it again.  This function has efficiency gains where
        join-objects are shared among the `objects` (querying all join-objects,
        then attaching them appropriately to each of the `objects`)
      </para>
    </refsect1>
    <refsect1>
      <title>Examples</title>
      <screen>
(defvar *addresses* (select 'deferred-employee-address :order-by [ea_join aaddressid] :flatp t))
=> *ADDRESSES*
(slot-boundp (car *addresses*) 'address)
=> NIL
(update-objects-joins *addresses*)
=> 
(slot-boundp (car *addresses*) 'address)
=> T
(slot-value (car *addresses*) 'address)
=> #&lt;ADDRESS {480B0F1D}>     
      </screen>
    </refsect1>
    <refsect1>
      <title>Side Effects</title>
      <para>
        The slot values of <parameter>objects</parameter> are modified. 
      </para>
    </refsect1>
    <refsect1>
      <title>Affected by</title>
      <para>
        <simplelist>
	  <member><link
	  linkend="default-update-objects-max-len"><varname>*default-update-objects-max-len*</varname></link></member>
	</simplelist>
      </para>
    </refsect1>
    <refsect1>
      <title>Exceptional Situations</title>
      <para>
	Database errors.
      </para>
    </refsect1>
    <refsect1>
      <title>See Also</title>
      <simplelist>
        <member><link linkend="default-update-objects-max-len"><varname>*default-update-objects-max-len*</varname></link></member>
        <member><link linkend="update-instance-from-records"><function>update-instance-from-records</function></link></member>
        <member><link linkend="update-slot-from-record"><function>update-slot-from-record</function></link></member>
      </simplelist>
    </refsect1>
    <refsect1>
      <title>Notes</title>
      <para>
        None. 
      </para>
    </refsect1>
  </refentry>

</reference>