:nulls-ok t
:initarg :email)
(companyid
- :type integer)
+ :type integer
+ :initarg :companyid)
(managerid
:type integer
- :nulls-ok t))
+ :nulls-ok t
+ :initarg :managerid))
(:base-table employee))
(clsql:def-view-class company ()
:type (string 100)
:initarg :name)
(presidentid
- :type integer))
+ :type integer
+ :initarg :presidentid))
(:base-table company))
</programlisting>
<listitem>
<para>
- <symbol>:db-type</symbol> - A string which will be used as the
+ <symbol>:column-</symbol> - A string which will be used as the
type specifier for this slots column definition in the database.
</para></listitem>
<listitem>
<para>
- <symbol>:nulls-ok</symbol> - If &t;, all &sql; &null; values
- retrieved from the database become nil; if &nil;, all &null;
- values retrieved are converted by
- <function>DATABASE-NULL-VALUE</function>. </para></listitem>
+ <symbol>:void-value</symbol> - The Lisp value to return if the
+ field is &null;. The default is &nil;.</para></listitem>
<listitem>
<para>
</para>
<para>
-Note: the file <filename>doc/clsql-tutorial.lisp</filename> contains
+Note: the file <filename>examples/clsql-tutorial.lisp</filename> contains
view class definitions which you can load into your list at this point
in order to play along at home.
</para>
</para>
<programlisting>
-(defvar employee1 (make-instance 'employee
- :emplid 1
- :first-name "Vladamir"
- :last-name "Lenin"
- :email "lenin@soviet.org"))
-
(defvar company1 (make-instance 'company
:companyid 1
+ :presidentid 1
:name "Widgets Inc."))
+(defvar employee1 (make-instance 'employee
+ :emplid 1
+ :first-name "Vladamir"
+ :last-name "Lenin"
+ :email "lenin@soviet.org"
+ :companyid 1))
(defvar employee2 (make-instance 'employee
:emplid 2
:first-name "Josef"
:last-name "Stalin"
- :email "stalin@soviet.org"))
+ :email "stalin@soviet.org"
+ :companyid 1
+ :managerid 1))
</programlisting>
<para>
(clsql:update-records-from-instance company1)
</programlisting>
-<para>
-Now we can set up some of the relations between employees and
-companies, and their managers. The
-<function>ADD-TO-RELATION</function> method provides us with an easy
-way of doing that. It will update both the relation slot, as well as
-the home-key and foreign-key slots in both objects in the relation.
-</para>
-
-<programlisting>
-;; Lenin manages Stalin (for now)
-(clsql:add-to-relation employee2 'manager employee1)
-
-;; Lenin and Stalin both work for Widgets Inc.
-(clsql:add-to-relation company1 'employees employee1)
-(clsql:add-to-relation company1 'employees employee2)
-
-;; Lenin is president of Widgets Inc.
-(clsql:add-to-relation company1 'president employee1)
-</programlisting>
-
<para>
After you make any changes to an object, you have to specifically
tell &clsql; to update the &sql; database. The