Skip to content

Ruby for Ingres via ODBC

Several months ago I decided to take a look at Ruby, in particular Rails, to see what all the fuss was about. Since Rails requires a database (of course) I thought I would see what could be done in getting it set up with Ingres. Since there is already someone working with a client of Ingres to produce a “native” Ingres driver for ruby I had a look at the ODBC offerings.

The default binding for ODBC appears to be available from http://www.ch-werner.de/rubyodbc/. Building the binding on Windows (this week I happen to be running windows) went ok. The subsequent tests did not go so well :( .

The following test fails:

$p = $c.proc("insert into test (id, str) values (?, ?)") {}
$p.call(3, "FOO")
$p[4, "BAR"]

An ODBC trace shows that integers as being passed to Ingres as SQL_VARCHAR. This sort of thing is allowed, if a little disagreable, with MySQL but Ingres does not like it.

If you apply the following patch to odbc.c the tests will complete:

diff -rup ruby-odbc-0.998/odbc.c ruby-odbc-0.998_patched/odbc.c
--- ruby-odbc-0.998/odbc.c      2006-05-21 09:38:30.000000000 +0200
+++ ruby-odbc-0.998_patched/odbc.c      2006-05-26 19:44:47.450091400 +0200
@@ -6151,6 +6151,7 @@ stmt_exec_int(int argc, VALUE *argv, VAL
        if (coldef == 0) {
            switch (ctype) {
            case SQL_C_LONG:
+               stype = SQL_INTEGER;
                coldef = 10;
                break;
            case SQL_C_DOUBLE:

Looking at the rest of the code more changes are needed since the ODBC binding sets the default type to SQL_VARCHAR without correcting for other types. If I get more time next week I will review the rest of the code in this function and post the complete diff.

Popularity: 15% [?]

  • Share/Bookmark

Some random posts

    6 Comments

    1. OpenLink Software will be releasing a RoR Data Adapter for Ingres.

      We are also completing a proper RoR Adaptor for ODBC/JDBC that will work with ODBC and JDBC accessible databases.

      You can pop me a mail if you are interested in a pre-release.

      Friday, May 26, 2006 at 5:05 pm | Permalink
    2. OpenLink Software will be releasing a RoR Data Adapter for Ingres.

      We are also completing a proper RoR Adaptor for ODBC/JDBC that will work with ODBC and JDBC accessible databases.

      You can pop me a mail if you are interested in a pre-release.

      Saturday, May 27, 2006 at 12:05 am | Permalink
    3. grant wrote:

      thanks Kingsley,

      I may take you up on that offer

      grant

      Saturday, May 27, 2006 at 8:23 am | Permalink
    4. grant wrote:

      thanks Kingsley,

      I may take you up on that offer

      grant

      Saturday, May 27, 2006 at 3:23 pm | Permalink
    5. Following up from Kingsley's post, we have test our own Ingres ODBC Driver against the Ruby ODBC Adapter(binding) and the SP test runs fine as our driver maps first param as a SQL_INTEGER.

      Also, if you are interested in testing a Pre-Release version of our RoR Data Adapter for Ingres then please let me know and I shall arrange to have this made available to you …

      Tuesday, May 30, 2006 at 11:25 am | Permalink
    6. Following up from Kingsley’s post, we have test our own Ingres ODBC Driver against the Ruby ODBC Adapter(binding) and the SP test runs fine as our driver maps first param as a SQL_INTEGER.

      Also, if you are interested in testing a Pre-Release version of our RoR Data Adapter for Ingres then please let me know and I shall arrange to have this made available to you …

      Tuesday, May 30, 2006 at 6:25 pm | Permalink

    One Trackback/Pingback

    1. An Ingres Blog / Ruby for Ingres on Monday, December 3, 2007 at 9:37 am

      [...] Sometime ago I wrote a quick post on getting the Ruby binding for ODBC working with Ingres. Whilst there is still some work to be done there I thought I might write about the Ingres Ruby binding and Ruby on Rails (RoR) adapter. [...]

    Post a Comment

    Your email is never published nor shared. Required fields are marked *
    *
    *
    blog comments powered by Disqus