Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re^7: SQL query using elements from array

by mje (Curate)
on Oct 13, 2014 at 12:16 UTC ( #1103618=note: print w/replies, xml ) Need Help??

in reply to Re^6: SQL query using elements from array
in thread SQL query using elements from array

Can you show us the schema for the table you are selecting from and the contens of $h->{ParamValues} after the execute (where $h is your statement handle). You might want to "use Data::Dumper" and "print Dumper($h->{ParamValues})". If you have RaiseError set you'll have to wrap the fetchrow_array in an eval or disable RaiseError to capture the ParamValues.

  • Comment on Re^7: SQL query using elements from array

Replies are listed 'Best First'.
Re^8: SQL query using elements from array
by AllPaoTeam (Acolyte) on Oct 13, 2014 at 17:35 UTC
    Can you write me an example, I am not sure how to do that. Thanks again for taking the time to help me. -Pao

      Try this, untested:

      use Data::Dumper; my $sth = $dbh->prepare($sql2); $dbh->{RaiseError} = 1; foreach my $i (0 .. @date1 - 1) { eval { $sth->execute($date1[$i], $date2[$i]); my @row; while (@row = $sth->fetchrow_array) { # retrieve one row at +a time print join(", ", @row), "\n"; } }; if ($@) { print "$@\n"; print Dumper($sth->{ParamValues}); } }
        Yea I ran this but got the error:
        Use of uninitialized value in subroutine entry at c:/Perl64/lib/DBD/OD line 166.
      Try running this script
      #!perl use strict; use DBI; my $dbh = dbh(); my $sql ="select * from information_schema.columns where table_name = ?"; my @tables = ('TopsData.dbo.AUDT_AuditChrt','TopsData.dbo.AUDT_AuditMe +dication'); for my $table (@tables){ my $ar = $dbh->selectall_arrayref($sql,undef,$table); for (@$ar){ print join ":",@$_,"\n"; } } # connect sub dbh { my $dsn = "dbi:ODBC:DSN=TEST-DB1"; my $dbh = DBI->connect($dsn, 'SA', 'pass', {RaiseError => 1, PrintError => 1}) or die (Error connecting " $DBI::errstr"); }
        Odd, it ran successfully but did not print anything, would you have an idea why?

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1103618]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2022-09-29 15:35 GMT
Find Nodes?
    Voting Booth?
    I prefer my indexes to start at:

    Results (125 votes). Check out past polls.