Dear Monks,
I am experiencing some problems with DBD::CSV. I have installed the modules and all the dependencies (Text::CSV_XS, SQL::Statement ... )
I even manage to make everything work the way I wanted there is just one problem at runtime when the code is excecuted.
With the following code (linux red hat 9, perl 5.8.0)
use strict; use warnings; use DBI; my $value = 45; my $dbh = DBI->connect("DBI:CSV:f_dir=.;csv_sep_char=\\;"); $dbh->{'csv_tables'}->{'my_table'} = { 'eol' => "\n", 'sep_char' => ";", 'quote_char' => undef, 'escape_char' => undef, 'file' => 'my_table.csv', 'col_names' => ["id", "value"] }; my $sth = $dbh->prepare(<<SQL); SELECT * FROM my_table WHERE value = ? SQL $sth->execute($value) or die "Cannot execute: " . $sth->errstr(); $sth->bind_columns( \my $ret_1, \my $ret_2 ); while ( $sth->fetch() ) { print "key($ret_1) value($ret_2)\n"; } $sth->finish(); $dbh->disconnect(); exit;
the file my_table.csv is as follow...
key;value 1;654 2;45 3;354 4;357 5;464 6;654 7;45 8;654 9;45 10;6546
Here is the output I get
Argument "value" isn't numeric in numeric eq (==) at /jey/.perl-lib/SQ +L/Statement.pm line 1120, <GEN0> line 1. key(2) value(45) key(7) value(45) key(9) value(45)
From what I understand, Perl is just complaining about the first line of my CSV file because the data is no integers, hence the <GEN0> line 1.
Does Anyone know how to get rid of this warning?
Furthermore I tried to do SQL commands like
SELECT * FROM table WHERE value = (SELECT * FROM table2 WHERE value2 = + ?)
This doesn't work, does anybody know why and if there is a way of getting round of this
In reply to Help with DBD::CSV by jey
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |