我正在尝试在 CLSQL 中使用微不足道的 SELECT。我尝试了很多排列,如下图:
(clsql:select 'dept_name
:from 'dept
:where (= 'dept_id 1))
;; Error
;; DEPT_ID is not of type NUMBER
;; though dept_id is of type INTEGER
(clsql:select 'dept_name
:from 'dept
:where [= id 'dept_id])
;; Error
;; The variable [= is unbound.
;; [Condition of type UNBOUND-VARIABLE]
(clsql:select [dept.dept_name]
:from [dept]
:where [= [dept.dept_id] 2])
;; Error
;; The variable [DEPT.DEPT_NAME] is unbound.
(clsql:select 'dept
:where [= [slot-value 'dept 'dept-id] 1])
;; Error
;; The variable [= is unbound.
;; [Condition of type UNBOUND-VARIABLE]
但是,查询
(clsql:select 'dept_name
:from 'dept)
返回一个元素(dept_name)
列表中的所有部门名称。
我已经声明了一个视图类。
(clsql:def-view-class dept ()
((dept-id
:db-kind :key
:db-constraints :not-null
:type integer
:initarg :dept-id)
(dept-name
:accessor dept-name
:type (string 10)
:initarg :dept-name))
(:base-table dept))
对应表dept
有两个属性。
我也启用了
(clsql:locally-enable-sql-reader-syntax)
我不知道我错过了什么以及如何让它发挥作用。