如何解决CLSQL:本地启用 sql reader 语法
我正在尝试在 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)
我不知道我缺少什么以及如何让它发挥作用。
解决方法
我认为我所有的实验都是错误的。首先,我们需要使用 (clsql:locally-enable-sql-reader-syntax)
而不是使用 (clsql:enable-sql-reader-syntax)
。 Locally 仅适用于文件内。请参阅 Reddit 论坛中的此 comment。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。