in reply to Extracting data using WIN32::ODBC

It is difficult to say. I could not duplicate your problem. Unfortunately, I had to change your code a fair amount to get it to run so it is possible that I modded out your problem. I'll make some general comments on the off chance that they help.

The error you describe refers, at least the times I have received it, to the fact that the variable $db has been undefined by the time you reach the statement if($db->Sql($sql)){ ... } Since the code seems OK, my first guess would be a scoping problem. That is, $db is going out of scope before your attempt to call Sql(). I note that your last right curly brace is commented out in your code. I needed to uncomment it to get the code to run at all.

You only reference $db twice before the Sql() call so I would next check there next.

A second guess would be the declaration or assignment to $db. You declare $db using a list context but don't actually assign to it so it remains undefined until you get to the new call. After that, it should contain a reference to the ODBC structure. I generally declare $db as my $db = ''; although I don't see how that matters here.

Ok, in looking back, I don't think I've offered much. With regard to ODBC, I've used it on Win32 successfully for several years. It does have some limitations though. I've never been able to get cursors to work, for example. Nor have I been able to fetch more than a single row at a time. I tried DBD::ODBC a few years ago without much success although I have heard of others who have not had a problem. In a recent node, Extracting data from an Ms ACCESS query, McMahon posted a message from David Roth that the Win32::ODBC module is no longer actively supported which is dissapointing. I checked CPAN and it does appear that DBD::ODBC is under active development. I will probably be experimenting with it a bit more now myself.

Good luck, I hope someone else can help :o)

PJ
We are drowning in information and starving for knowledge - Rutherford D. Rogers
What good is knowledge if you have to pull teeth to get it - anonymous