我尝试在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)我不知道我错过了什么,也不知道如何让它工作。
发布于 2021-06-27 11:36:22
我想我所有的实验都是错的。首先,我们需要使用(clsql:enable-sql-reader-syntax)而不是(clsql:locally-enable-sql-reader-syntax)。Locally仅适用于文件内。请参考Reddit论坛中的此comment。
https://stackoverflow.com/questions/68141181
复制相似问题