[plt-scheme] SrPersist Question
I am using SrPersist to connect PLT-Scheme to MySQL on
Mac OS X. I am using the following code which makes it
easy for me to query and uses some procedures borrowed
from the SchemeQL odbc.ss file.
(define (retrieve-data dbname user password
sql-statement)
(let ((all-records null))
(let ((henv (alloc-env)))
(let ((hdbc (alloc-connect henv)))
(begin
(connect hdbc dbname user password)
(let ((hstmt (alloc-stmt hdbc)))
(begin
(prepare hstmt sql-statement)
(sql-execute hstmt)
(let-values (((buffers indicators
columns) (create-column-buffers hstmt)))
(with-handlers
([(lambda (exn) (exn-no-data?
exn))
(lambda (exn) (reverse
all-records))])
(let loop ()
(fetch hstmt)
(let ((record (apply append (map
read-buffer buffers))))
(set! all-records (cons record
all-records)))
(loop)))))))))))
I call this as followes
(retrieve-data "mysqltest" "mysql" "" "select * from
blah")
I got this working after some struggle and I wonder if
an explicit close to the connection is required
somewhere???
Sidebar : I think there is a bug in the dependent SQL
types in the dependent-sql-types proc in the schemeql
odbc.ss file which tries to return 'sql-c-numeric and
gives an error.
__________________________________
Do you Yahoo!?
Yahoo! Domains Claim yours for only $14.70/year
http://smallbusiness.promotions.yahoo.com/offer