[plt-scheme] schemeql
Michael Sperber wrote:
> I seem to remember there are 3 our 4 different "connect"-like
> procedures in ODBC/SrPersist, and SchemeQL only goes through one of
> them while SQL Server wants another. Which exact call are you using
> to connect via vanilla SrPersist?
I'm using: (connect hdbc database uid password).
BTW, for SchemeQL the actual (connect-to-database ...) call appears to
succeed - the exception occurs when 'schemeql-execute' is called. FWIW, I
traced the execution path in SchemeQL up to the driver-query function, but
realized I don't know how to debug inside a PLT module: I can't call
functions like sr:prepare or sr:sql-execute from the REPL, because they're
hidden by SrPersist's odbc module.
I did notice that using SrPersist directly, when functions like 'connect'
are invoked, DrScheme returns the ladybug icon with a status message such as
"SQL_SUCCESS_WITH_INFO occurred in connect". Because of this, I can't
execute a script all at once, since it stops whenever it gets to such a
statement. I assumed that SchemeQL does whatever it needs to to deal with
this, though.
Here's one of the tests I did with SrPersist (based on its tutorial):
(require (lib "srpersist.ss" "srpersist"))
(define henv (alloc-env))
(define hdbc (alloc-connect henv))
(connect hdbc "mydb" "sa" "the-password")
(define hstmt (alloc-stmt hdbc))
(prepare hstmt "select companies.name from companies where
companies.id=777")
(sql-execute hstmt)
(define name-buffer (make-buffer '(sql-c-char 50)))
(define name-indicator (make-indicator))
(bind-col hstmt 1 name-buffer name-indicator)
(with-handlers
([(lambda (exn) (exn-no-data? exn))
(lambda (exn) (printf "** End of data **~n"))])
(let loop ()
(fetch hstmt)
(printf "Name: ~a~n"
(read-buffer name-buffer))
(loop)))
Other than the status messages, this worked fine and printed the correct
data.
Anton