[plt-scheme] Advise debugging my srpersist connection (w/ postgres)

From: Paul Steckler (steck at ccs.neu.edu)
Date: Tue Sep 10 11:16:31 EDT 2002

> (lib-"srpersist.ss" "srpersist"))
> (define r-env-h (alloc-handle 'sql-handle-env))
> (define r-con-h (alloc-handle 'sql-handle-dbc r-env-h))
> (define r-stmt-h (alloc-handle 'sql-handle-stmt r-con-h))
> The last call to "alloc-handle" returns:
> "Unspecified error in alloc-handle".

You might want to try using sql-error or get-diag-rec to get more error

I'm not sure it's the problem, but the docs for alloc-handle mention:

	Before using `alloc-handle' to create a connection handle, you
	 need to call `set-env-attr' with 'sql-attr-odbc-version and 
	'sql-ov-odbc3 as arguments.

> I then tried:
> (drivers r-env-h 'sql-fetch-first)
> -AND-
> (drivers r-env-h 'sql-fetch-next)
> instead of the final define to get the statement handle.  Both of the
> calls to the "drivers" method return:
> "SQL_NO_DATA error in drivers"

Maybe there are no drivers loaded?  IIRC, iODBC has an .ini file that
specifies the drivers to use.
> Can someone offer some debugging tips?  Can I explicitly specify a
> connect string somewhere? 

Yes, use the `driver-connect' procedure.

> Is there some verbose error checking
> offered
> by DrScheme so I can determine the "Unspecified error" I'm getting?

As suggested above, the `sql-error' and `get-diag-rec' procedures give
info about the last ODBC error.

-- Paul

Posted on the users mailing list.