Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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 +BC.pm 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"); }
      poj
        Odd, it ran successfully but did not print anything, would you have an idea why?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2019-04-26 00:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I am most likely to install a new module from CPAN if:
















    Results (127 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!