projects
/
clsql.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
1f3f2d9
)
r8901: package name fixes
author
Kevin M. Rosenberg
<kevin@rosenberg.net>
Fri, 9 Apr 2004 02:13:32 +0000
(
02:13
+0000)
committer
Kevin M. Rosenberg
<kevin@rosenberg.net>
Fri, 9 Apr 2004 02:13:32 +0000
(
02:13
+0000)
doc/clsql-tutorial.lisp
patch
|
blob
|
history
diff --git
a/doc/clsql-tutorial.lisp
b/doc/clsql-tutorial.lisp
index 9c9b93f9a287bb709580f173cedbd3ac6eee91e9..2afb0f8e020312178a86c223b2782ddd47a0cff6 100644
(file)
--- a/
doc/clsql-tutorial.lisp
+++ b/
doc/clsql-tutorial.lisp
@@
-1,5
+1,6
@@
+(asdf:operate 'asdf:load-op 'clsql)
-(in-package
:c
l-user)
+(in-package
#:clsq
l-user)
;; You must set these variables to appropriate values.
(defvar *tutorial-database-type* nil
;; You must set these variables to appropriate values.
(defvar *tutorial-database-type* nil
@@
-13,7
+14,7
@@
(defvar *tutorial-database-password* ""
"The password if required")
(defvar *tutorial-database-password* ""
"The password if required")
-(sql:def-view-class employee ()
+(
cl
sql:def-view-class employee ()
((emplid
:db-kind :key
:db-constraints :not-null
((emplid
:db-kind :key
:db-constraints :not-null
@@
-54,7
+55,7
@@
:set nil)))
(:base-table employee))
:set nil)))
(:base-table employee))
-(sql:def-view-class company ()
+(
cl
sql:def-view-class company ()
((companyid
:db-type :key
:db-constraints :not-null
((companyid
:db-type :key
:db-constraints :not-null
@@
-83,7
+84,7
@@
;; Connect to the database (see the CLSQL documentation for vendor
;; specific connection specs).
;; Connect to the database (see the CLSQL documentation for vendor
;; specific connection specs).
-(sql:connect `(,*tutorial-database-server*
+(
cl
sql:connect `(,*tutorial-database-server*
,*tutorial-database-name*
,*tutorial-database-user*
,*tutorial-database-password*)
,*tutorial-database-name*
,*tutorial-database-user*
,*tutorial-database-password*)
@@
-91,16
+92,16
@@
;; Record the sql going out, helps us learn what is going
;; on behind the scenes
;; Record the sql going out, helps us learn what is going
;; on behind the scenes
-(sql:start-sql-recording)
+(
cl
sql:start-sql-recording)
;; Create the tables for our view classes
;; First we drop them, ignoring any errors
(ignore-errors
;; Create the tables for our view classes
;; First we drop them, ignoring any errors
(ignore-errors
- (sql:drop-view-from-class 'employee)
- (sql:drop-view-from-class 'company))
+ (
cl
sql:drop-view-from-class 'employee)
+ (
cl
sql:drop-view-from-class 'company))
-(sql:create-view-from-class 'employee)
-(sql:create-view-from-class 'company)
+(
cl
sql:create-view-from-class 'employee)
+(
cl
sql:create-view-from-class 'company)
;; Create some instances of our view classes
;; Create some instances of our view classes
@@
-122,22
+123,22
@@
:email "stalin@soviet.org"))
;; Lenin manages Stalin (for now)
:email "stalin@soviet.org"))
;; Lenin manages Stalin (for now)
-(sql:add-to-relation employee2 'manager employee1)
+(
cl
sql:add-to-relation employee2 'manager employee1)
;; Lenin and Stalin both work for Widgets Inc.
;; Lenin and Stalin both work for Widgets Inc.
-(sql:add-to-relation company1 'employees employee1)
-(sql:add-to-relation company1 'employees employee2)
+(
cl
sql:add-to-relation company1 'employees employee1)
+(
cl
sql:add-to-relation company1 'employees employee2)
;; Lenin is president of Widgets Inc.
;; Lenin is president of Widgets Inc.
-(sql:add-to-relation company1 'president employee1)
+(
cl
sql:add-to-relation company1 'president employee1)
-(sql:update-records-from-instance employee1)
-(sql:update-records-from-instance employee2)
-(sql:update-records-from-instance company1)
+(
cl
sql:update-records-from-instance employee1)
+(
cl
sql:update-records-from-instance employee2)
+(
cl
sql:update-records-from-instance company1)
;; lets us use the functional
;; sql interface
;; lets us use the functional
;; sql interface
-(sql:locally-enable-sql-reader-syntax)
+(
cl
sql:locally-enable-sql-reader-syntax)
(format t "The email address of ~A ~A is ~A"
(format t "The email address of ~A ~A is ~A"
@@
-148,10
+149,10
@@
(setf (employee-email employee1) "lenin-nospam@soviets.org")
;; Update the database
(setf (employee-email employee1) "lenin-nospam@soviets.org")
;; Update the database
-(sql:update-records-from-instance employee1)
+(
cl
sql:update-records-from-instance employee1)
(let ((new-lenin (car
(let ((new-lenin (car
- (sql:select 'employee
+ (
cl
sql:select 'employee
:where [= [slot-value 'employee 'emplid] 1]))))
(format t "His new email is ~A"
(employee-email new-lenin)))
:where [= [slot-value 'employee 'emplid] 1]))))
(format t "His new email is ~A"
(employee-email new-lenin)))
@@
-160,19
+161,19
@@
;; Some queries
;; all employees
;; Some queries
;; all employees
-(sql:select 'employee)
+(
cl
sql:select 'employee)
;; all companies
;; all companies
-(sql:select 'company)
+(
cl
sql:select 'company)
;; employees named Lenin
;; employees named Lenin
-(sql:select 'employee :where [= [slot-value 'employee 'last-name]
+(
cl
sql:select 'employee :where [= [slot-value 'employee 'last-name]
"Lenin"])
"Lenin"])
-(sql:select 'company :where [= [slot-value 'company 'name]
+(
cl
sql:select 'company :where [= [slot-value 'company 'name]
"Widgets Inc."])
;; Employees of Widget's Inc.
"Widgets Inc."])
;; Employees of Widget's Inc.
-(sql:select 'employee
+(
cl
sql:select 'employee
:where [and [= [slot-value 'employee 'companyid]
[slot-value 'company 'companyid]]
[= [slot-value 'company 'name]
:where [and [= [slot-value 'employee 'companyid]
[slot-value 'company 'companyid]]
[= [slot-value 'company 'name]