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

I'm modifying a Web application that currently creates Microsoft Access 2003 files, but also needs to create Access 2007 files.

I updated the connection string in the function in a perl module so it specifies '.accdb' files in addition to '.mdb' files. However, when I try to test the code to create an Access 2007 file, I see the following error message in a log file:

Describe failed during DBI::st=HASH(0x40f84d4)->FETCH(NAME,0) at lib/searchInstance.pm line 784.
Can't set DBI::HASH(0x40f84d4)->{NAME_uc}: unrecognised attribute name or invalid value at lib/searchInstance.pm line 784.

Here is line 784:

foreach my $i (0..$#{dst_info_sth->{NAME_uc}}) {

$dst_info_sth represents a database statement handle:
...
my $dst_info_sql = "SELECT * FROM $to";
...
my $dst_info_sth = $dst_dbh->prepare($dst_info_sql);
...


Any ideas/suggestions to resolve this would be greatly appreciated.

Replies are listed 'Best First'.
Re: Using Microsoft Access 2007 with DBI
by mje (Curate) on Jun 30, 2011 at 07:29 UTC

    You seem to have posted this on the dbi-users mailing list as well. Generally it is a good idea to mention that when posting as you are dividing the discussion. I answered you on the dbi-users list. Can you provide a trace file for a run of your code that fails. To do that set DBI_TRACE=15=x.log then run the code. Then put the x.log file somewhere I can see it.

Re: Using Microsoft Access 2007 with DBI
by NetWallah (Canon) on Jun 30, 2011 at 00:50 UTC
    It looks like this line may be missing a "$" : Here is how I think it should look:
    foreach my $i (0..$#{$dst_info_sth->{NAME_uc}}) { # "$" added in fro +nt of "dst_info_sth"
    Update:Ignore this - the original syntax is valid.

    Another suggestion is to use the perl debugger, and set a breakpoint at the failing line of code, then examine the variables involved.

                "XML is like violence: if it doesn't solve your problem, use more."

Re: Using Microsoft Access 2007 with DBI
by Anonymous Monk on Jun 30, 2011 at 04:18 UTC

    unrecognised attribute name or invalid value

    You don't show the code where you set whatever invalid attribute you're setting.

    Showing us unrelated pseudocode won't help you solve your problem, see How do I post a question effectively?

      The 'unrecognised attribute' is 'NAME_uc', as indicated in the 'foreach' line of code (not 'pseudocode') included in my original message.

      As it turns out, the reason for the error message is the table whose name is stored in the '$to' variable doesn't exist.

      (A little more background info which I probably should have provided is the code is part of a function for copying data from a table in an Oracle database to its 'counterpart' table in an Access database. A new Access database I'm trying to get the code to work with doesn't have all the tables the perl code is expecting)