;; You must set these variables to appropriate values.
(defvar *tutorial-database-type* nil
- "Possible values are :postgresql,:postgresql-socket :mysql or :sqlite")
-(defvar *tutorial-database-name* ""
+ "Possible values are :postgresql :postgresql-socket, :mysql,
+:oracle, :odbc, :aodbc or :sqlite")
+(defvar *tutorial-database-name* "clsqltut"
"The name of the database we will work in.")
(defvar *tutorial-database-user* ""
"The name of the database user we will work as.")
:type (string 100)
:initarg :email)
(companyid
- :type integer)
+ :type integer
+ :initarg :companyid)
(company
:accessor employee-company
:db-kind :join
;; Connect to the database (see the CLSQL documentation for vendor
;; specific connection specs).
-(clsql:connect `(,*tutorial-database-server*
- ,*tutorial-database-name*
- ,*tutorial-database-user*
- ,*tutorial-database-password*)
- :database-type *tutorial-database-type*)
+(case *tutorial-database-type*
+ ((:mysql :postgresql :postgresql-socket)
+ (clsql:connect `(,*tutorial-database-server*
+ ,*tutorial-database-name*
+ ,*tutorial-database-user*
+ ,*tutorial-database-password*)
+ :database-type *tutorial-database-type*))
+ ((:odbc :aodbc :oracle)
+ (clsql:connect `(,*tutorial-database-name*
+ ,*tutorial-database-user*
+ ,*tutorial-database-password*)
+ :database-type *tutorial-database-type*))
+ (:sqlite
+ (clsql:connect `(,*tutorial-database-name*)
+ :database-type *tutorial-database-type*)))
;; Record the sql going out, helps us learn what is going
;; on behind the scenes
(let ((new-lenin (car
(clsql:select 'employee
- :where [= [slot-value 'employee 'emplid] 1]))))
+ :where [= [slot-value 'employee 'emplid] 1]
+ :flatp t))))
(format t "His new email is ~A"
(employee-email new-lenin)))