X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=examples%2Fclsql-tutorial.lisp;h=118ea2023ddb2f95756e6998460ef4ffce27e8a7;hb=d9f41af62750c622945bb17b622a39689ee5b840;hp=cf27468c167f71a98f3b29e838337f39d395594d;hpb=9f1b97ba188b6c065146fc2cb7e818e5c62b7175;p=clsql.git diff --git a/examples/clsql-tutorial.lisp b/examples/clsql-tutorial.lisp index cf27468..118ea20 100644 --- a/examples/clsql-tutorial.lisp +++ b/examples/clsql-tutorial.lisp @@ -4,8 +4,9 @@ ;; 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.") @@ -18,7 +19,6 @@ ((emplid :db-kind :key :db-constraints :not-null - :nulls-ok nil :type integer :initarg :emplid) (first-name @@ -32,10 +32,10 @@ (email :accessor employee-email :type (string 100) - :nulls-ok t :initarg :email) (companyid - :type integer) + :type integer + :initarg :companyid) (company :accessor employee-company :db-kind :join @@ -45,7 +45,6 @@ :set nil)) (managerid :type integer - :nulls-ok t :initarg :managerid) (manager :accessor employee-manager @@ -86,11 +85,21 @@ ;; 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) + (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 @@ -148,7 +157,8 @@ (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)))