2015-07-20 42 views
1

我的计划是做一个选择是这样的:怎样才能得到打印的标量球拍

(define latest-withdrawal-date 
(for/list ([(date-wdrl) 
(in-query odc "select max(student_withdrawal_date) from student_enrollement 
where student_id = ? " my_student_id)))) 

非但没有回来的日期,虽然,我回来#<procedure:date-wdrl>

那么我怎样才能得到日期显示,而不是被遮蔽?

+1

此代码是语法不正确,所以这是很难诊断可能是什么问题。看起来好像您的查询正在返回一个过程作为日期时间对象的表示。尝试util包以转换为srfi/19的日期时间进行打印。 http://docs.racket-lang.org/db/util.html –

+0

我可以在其他查​​询中收集返回行数的日期字段。最后的父母是错误的,因为我不知道如何让他们在维基标记中保持一致。 – bentaisan

回答

1

使用query-value得到标量结果。

从文档:

(query-value connection stmt arg ...) → any/c 
Executes a SQL query, which must produce exactly one row 
of exactly one column, and returns its single value result. 

Examples: 
> (query-value pgc "select timestamp 'epoch'") 
(sql-timestamp 1970 1 1 0 0 0 0 #f) 
> (query-value pgc "select d from the_numbers where n = $1" 3) 
"a crowd"