[plt-scheme] A bug of srpersist?
I write the following code:
(require (lib "srpersist.ss" "srpersist"))
(define henv (alloc-env))
(define hdbc (alloc-connect henv))
(connect hdbc "system" "" "")
(let ((hstmt (alloc-stmt hdbc)))
(prepare hstmt "USE system")
(sql-execute hstmt))
(define (q1)
(define id-buffer (make-buffer 'sql-c-slong))
(define name-buffer (make-buffer '(sql-c-char 20)))
(define tele-buffer (make-buffer '(sql-c-char 20)))
(define add-buffer (make-buffer '(sql-c-char 20)))
(define time-buffer (make-buffer 'sql-c-timestamp))
(define state-buffer (make-buffer '(sql-c-char 10)))
(define id-indicator (make-indicator))
(define name-indicator (make-indicator))
(define tele-indicator (make-indicator))
(define add-indicator (make-indicator))
(define time-indicator (make-indicator))
(define state-indicator (make-indicator))
(define hstmt (alloc-stmt hdbc))
(define al '())
(prepare hstmt "select id, name, tele, address, time1, state from bx;")
(sql-execute hstmt)
(bind-col hstmt 1 id-buffer id-indicator)
(bind-col hstmt 2 name-buffer name-indicator)
(bind-col hstmt 3 tele-buffer tele-indicator)
(bind-col hstmt 4 add-buffer add-indicator)
(bind-col hstmt 5 time-buffer time-indicator)
(bind-col hstmt 6 state-buffer state-indicator)
(with-handlers
([(lambda (exn) (exn-no-data? exn))
(lambda (exn) (void))])
(let loop ()
(newline)
(display id-buffer) ;first display
(fetch hstmt)
(newline)
(display id-buffer) ;second display
(set! al (cons (list (car (read-buffer id-buffer))
(car (read-buffer name-buffer))
(car (read-buffer tele-buffer))
(car (read-buffer add-buffer))
(let ((time1 (car (read-buffer time-buffer))))
(string-append (number->string (sql-timestamp-year time1))
"-"
(number->string (sql-timestamp-month time1))
"-"
(number->string (sql-timestamp-day time1))
" "
(number->string (sql-timestamp-hour time1))
":"
(number->string (sql-timestamp-minute time1))))
(car (read-buffer state-buffer)))
al))
(loop)))
al)
(q1)
When running(Windows XP + DrScheme 206p1 + ODBC), the first display
displays "#<sql-buffer>" and the second displays "1277974".
What's wrong?
=========================================
>Hi all,
>
>When writing something with srpersist, I meet the following problem:
>
>First I wrote the some code like the p1.scm. When it runs, a error occured at line
>31, the "(read-buffer id-buffer)". The error messege is always "read-buffer:
>expects argument of type <<sql-buffer>>; given 1277974 " .
>
>I try to debug and rewrite the code into the p2.scm. But this time it works and
>give the desired output!
>
>I can't find any reason why these two codes should behave differently. The
>circumstance is same and the ODBC and DBMS works well. What's wrong with the
>p1.scm?
>
>Zhu Chongkai
>