Using the IBM_DB Ruby gem with DB2

You may also like...

5 Responses

  1. Dick Rietveld says:

    They already knew back in 1970:

  2. Great article. I followed a very similar path (Perl to Ruby) a while ago, having been encouraged to look at Ruby on Rails with DB2 by Leon Katsnelson.

    Found the Ruby driver developers to be very responsive to problem reports : often fixing the issue and sending me a new drop of the driver code within minutes.

    Is your foray into Ruby as a general purpose language or as part of a Rails development? If the latter then Rails takes care of a lot of the complexities which you’ve described above. If the former then you really should check out (if you’ve not done so already) the Ruby books from Pragmatic Programmers (particularly the “Pickaxe book” which is virtually the Ruby language manual !!!).

    I did a couple of sessions on RoR with DB2 at IDUG a few years ago. You should be able to dig these out of the IDUG archives. I’d be interested in seeing how things have progressed since then, since I’ve been so busy on other things that I’ve not really been keeping up with the Ruby world.

    • Ember Crooks says:

      I’m using it without Rails. A teammate is using it for some other things, so I have to either hand some of my script development over to him or learn it myself. I like the opportunity to learn something new, and the teammate has built an interesting framework, and the OO way that he’s doing things is interesting. When using Perl, I had never really used the DBI, so that’s new to me too. The learning curve is a bit steep at the moment, but I’ll get there. We’re considering moving all of our DB maintenance scripts from Perl to Ruby, but haven’t made a final decision there.

  3. Jeff B. says:

    Great writeup! It’s so nice to see people using Ruby with DB2 in 2014. If anyone’s looking for a way to use bound parameters with DB2, the syntax is like this (in this example, I’m creating a record in DB2 from a Ruby hash):

    stmt = IBM_DB.prepare(conn, sql)

    IBM_DB.bind_param(stmt, 1, song[‘ID’])
    IBM_DB.bind_param(stmt, 2, song[‘TITLE’])
    IBM_DB.bind_param(stmt, 3, song[‘ARTIST’])

    if IBM_DB.execute(stmt)
    puts “Inserted a row.”
    puts IBM_DB.stmt_errormsg(stmt)

  1. February 18, 2014

    […] Using the IBM_DB Ruby gem with DB2 […]

Leave a Reply

Your email address will not be published. Required fields are marked *