JL has asked for the wisdom of the Perl Monks concerning the following question:

I want to connect my Perl program to a Mimer database. The only way I can do this is through an ODBC interface. The question is how do I do this?

In other words, what piece of code connect perl through ODBC to the mimer database.

I have tried the following whithout success:

use DBI; $ dbh = DBI->connect("dbi:ODBC:KURS","userid","password") ||die print $DBI::errstr; $mot=$dbh->prepare("SELECT * from test1"); $mot->execute; $mot->finish; $dbh->disconnect;
As a result I get a segmentation fault (core dump)! What's wrong?

I appreciate any help I can get. /Johan

update Masem - fixed typo in title

Edit by tye - moved to SOPW and HTMLized formatting

  • Comment on What code should I write in Perl to connect to an ODBC DB on a linux platform?
  • Download Code

Replies are listed 'Best First'.
Re: What code should I write in Perl to connect to an ODBC DB on a linux platform?
by Arguile (Hermit) on Jun 19, 2001 at 03:49 UTC

    A segfault is a rather extreme error, try below in a step by step manner to try isolating where/what is causing it.

    Specifically:
    • I'll assume you're using use strict and -w :).
    • You're using double quotes around the dbi:ODBC:datasource where you should be using single quotes. Double quotes interpolate, single don't.
    • Next you could add some more error handling $sth = $dbh->prepare("SELECT * FROM table") or die "error message here" and other locations to help track it down (and strictly speaking prepare isn't needing for a query like this but that's a non-issue).
    In General: