I have a simple script which converts access tables to XML.

use XML::Simple; use Data::Dumper; use DBI; my $config = XMLin('c:\website\config.xml', forcearray => qr/table/ ) or die ("unable to open config file"); my ($access_database) = @{$config->{database}}; my ($results_directory) = @{$config->{results_directory}}; my $dsn = "driver=Microsoft Access Driver (*.mdb);dbq=$access_database +"; my $driver = "dbi:ODBC:$dsn"; my $username = ''; my $password = ''; my $dbopt = { PrintError => 0, RaiseError => 0 }; open (LOG,'>c:\website\log.txt') or die "log $!"; my $dbh = DBI->connect($driver, $username, $password, $dbopt) or die "Error connecting: $DBI::errstr"; for $extract (@{$config->{extract}}) { my $results_file = $extract->{file}; my @results; my $ref; for $table (@{$extract->{table}}) { my $sql = "SELECT * FROM $table"; my $sth = $dbh->prepare($sql) or die "Unable to prepare ($sql): ", $dbh->errstr;; $sth->execute or die "Unable to execute ($sql): ", $sth->errstr; $ref->{$table} = $sth->fetchall_arrayref({}); } my $results = XMLout($ref,rootname=>'root', noattr=>1); print LOG Dumper $ref; print LOG $results; print LOG "\n\n"; local *RESXML; open (RESXML, ">$results_directory\\$results_file") or die ("Unable to open results file $results_directory\\$results_fil +e: $!"); print RESXML $results; }

I can't hand out the database, but I can tell you it's pretty simple with a few numeric, date, memo, and text fields.

The problem is that some result sets are empty, even though the database table is populated.

So, I did a little test. I wrote a small script which did nothing more than select * from accommodation. That didn't work. I got no rows in my results set at all.

If I did select count(*) from accommodation, I got the count of the rows.</p?

If I did select <field> from accommodation, that worked fine.

I am more stumped that stumpy the stumpy dwarf.

--
¤ Steve Marvell


In reply to MS Access empty results by marvell

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.