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

--
jey

In reply to Help with DBD::CSV by jey

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.