Lisp HUG Maillist Archive

ODBC on Linux

Does anyone have used it successfully? 

What were the steps you have done?


I tried with unixODBC and MYODBC. The examples in that packages run
fine, but I wasn't able to connect to the database with CommonSQL.


Regards
Friedrich


Re: ODBC on Linux

Am Don, 2002-03-07 um 09.23 schrieb Friedrich Dominicus:
> Does anyone have used it successfully? 
> 
> What were the steps you have done?
> 
> 
> I tried with unixODBC and MYODBC. The examples in that packages run
> fine, but I wasn't able to connect to the database with CommonSQL.

I have it running I used the unixODBCs of the site

  http://edas.visaci.cz/en/unixodbc/

I also installed the GTK+ Driver Manager from the same site.
On by machine runs PostgreSQL 7.1.3 which I first tested with "psql".

Then I started "gODBCConfig" which is the GTK+ Driver Manager.
If you installed all packages correctly there should be an entry for
PostgreSQL in the List under the "Drivers" tab.

I clicked on the tab "User DSN" and hit the "Add" Button.
A new window pops up which shows all installed drivers (in my case only
PostgeSQL). I selected it and clicked on "Ok".

After that a window appeared where one can setup the details of the
UserDSN.

I gave the DSN the name "jsc".
"Database" was "jsc" too which is the name of a Database I created with
PostgreSQL. I supplied Username and Password of the PostgreSQL database
user. Then I changed the "ReadOnly" Selector from "Yes" to "No" and
clicked on the "Ok" button of the dialog.

After that I closed the Driver Manager Window.

Now I started LispWorks and CommonSQL

CL-USER 1 > (require "odbc")

And connected to the database:

CL-USER 2 > (sql:connect "jsc/thepassword")

One thing that not worked was CREATE-VIEW-FROM-CLASS

CL-USER 3 > (sql:def-view-class a () ((aslot :type fixnum)))
CL-USER 4 > (sql:create-view-from-class 'a)
Error: Schema querying not implemented for database
#<SQL::POSTGRESQL-ODBC-DATABASE "jsc/thepassword" 2067F0B4>
  1 (abort) Return to level 0.
  2 Return to top loop level 0.
....
CL-USER 5 : 1 > :b
Call to (METHOD SQL::TABLE-EXISTS (SQL-COMMON:DATABASE T))
Call to SQL:CREATE-VIEW-FROM-CLASS
Call to SPECIAL::%EVAL-NOHOOK
Call to IV:PROCESS-TOP-LEVEL
Call to CAPI::CAPI-TOP-LEVEL-FUNCTION
Call to CAPI::INTERACTIVE-PANE-TOP-LOOP
Call to (SUBFUNCTION 1 MP::INITIALIZE-PROCESS-STACK)

Defining a method as follows lets you at least create and use the table:

CL-USER 6 : 1 > (defmethod sql::table-exists ((db
sql::postgresql-odbc-database) table) nil)

CL-USER 7 : 1 > :a
CL-USER 8 > (sql:create-view-from-class 'a)
NIL
CL-USER 9 > (sql:commit)
NIL
CL-USER 10 > (sql:list-tables)
("a")
CL-USER 11 > (setf *a* (make-instance 'a))
CL-USER 12 > (setf (slot-value *a* 'aslot) 1)
CL-USER 13 > (sql:update-records-from-instance *a*)
CL-USER 14 > (sql:commit)
CL-USER 15 > (sql:select 'a)
((#<db-instance A 543726476>))
CL-USER 16 > (slot-value (first (first *)) 'aslot)
1
CL-USER 17 > (sql:disconnect)


The SQL::TABLE-EXISTS method could probably be implemented by using
(sql:list-tables) but I have no idea whats going wrong.

ciao,
Jochen


Updated at: 2020-12-10 09:02 UTC