Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^6: SQL query using elements from array

by AllPaoTeam (Acolyte)
on Oct 13, 2014 at 03:25 UTC ( #1103581=note: print w/replies, xml ) Need Help??


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

Yes, I would really appreciate it someone could help me solve this issue, below is the full error:
DBD::ODBC::st execute faile: [Microsoft}[ODBC SQL Server Driver][SQL S +erver Conversion failed when converting data and/or time from charact +er string. (SQL-22007) at test10.pl line 40. DBD::ODBC::st fetchrow_a +rray failed: no select statement currently executing (SQL-HY000) at t +est10.pl line 42.
It repeats that twice. Thanks again!!!

Replies are listed 'Best First'.
Re^7: SQL query using elements from array
by mje (Curate) on Oct 13, 2014 at 12:16 UTC

    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.

      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}); } }
        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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2020-12-01 16:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (13 votes). Check out past polls.

    Notices?