Hello Monks!

I am running sql queries on a spreadsheet. Some of the cells have no value in them. For example, some patients have no record of their viral DNA level at treatment week 12 (column dnatw12). When I try to skip these blank fields using 'IS NOT NULL' I get an error message {DBD::CSV::st execute failed: Can't locate object method "do_err" via package "SQL::Statement::Function::NumericEval"}

My Perl code for the sql search is below

#!/usr/bin/perl use strict; use warnings; use Text::CSV; use DBI; sub RunSqlSearch; my $spreadsheet = 'newCsv.csv'; my $query = qq(SELECT sid,genotype, dnabl, dnatw12 FROM $spreadsheet W +HERE genotype = 'a' AND (dnatw12/dnabl)<0.5 AND dnatw12 IS NOT NULL ) +; my ($queryResult) = RunSqlSearch($query); print "Your query $query returned the following result:\n$queryResult\ +n"; sub RunSqlSearch($){ my $query = $_[0]; # error check # if ($query eq ""){die "From runSqlQuery2 - No value entered for $ +query $!\n";} # Connect to the database, (the directory containing our csv file +(s)) my $dbh = DBI->connect ("dbi:CSV:", undef, undef, { f_dir => ".", # f_ext => ".csv/r", f_encoding => "utf-8", csv_eol => "\n", RaiseError => 1, }) or die $DBI::errstr; # Output using sql query # my $sth = $dbh->prepare($query); if($sth){ $sth ->finish(); } $sth->execute; my @row; my $queryResult=""; my @queryResult; while (@row = $sth->fetchrow_array) { push @queryResult, @row; $queryResult .= join("\t",@row) . "\n"; } # output arguments # if ($queryResult eq ""){$queryResult = "No result found";} return ($queryResult); $sth->finish(); $dbh->disconnect(); }

My full error message is below

DBD::CSV::st execute failed: Can't locate object method "do_err" via p +ackage "SQL::Statement::Function::NumericEval" at C:/Strawberry/perl/ +vendor/lib/SQL/Statement/Function.pm line 216, <GEN1> line 37. [for Statement "SELECT sid,genotype, dnabl, dnatw8 FROM newCsv.csv WH +ERE genotype = 'a' AND (dnatw12/dnabl)<0.5 AND dnatw12 IS NOT NULL "] + at C:/Users/Sandy/Documents/PC_Bioinformatics_MSc/Project/Perl/runSQ +LQuery2.pl line 38, <GEN1> line 37. DBD::CSV::st execute failed: Can't locate object method "do_err" via p +ackage "SQL::Statement::Function::NumericEval" at C:/Strawberry/perl/ +vendor/lib/SQL/Statement/Function.pm line 216, <GEN1> line 37. [for Statement "SELECT sid,genotype, dnabl, dnatw8 FROM newCsv.csv WH +ERE genotype = 'a' AND (dnatw12/dnabl)<0.5 AND dnatw12 IS NOT NULL "] + at C:/Users/Sandy/Documents/PC_Bioinformatics_MSc/Project/Perl/runSQ +LQuery2.pl line 38, <GEN1> line 37.

When I run a query using columns that do not contain blanks - details for treatment week 8 are complete for all patients e.g. qq(SELECT sid,genotype, dnabl, dnatw8 FROM $spreadsheet WHERE genotype = 'a' AND (dnatw8/dnabl)<0.5 AND dnatw8 IS NOT NULL ); The query works perfectly.

I would be very grateful for any advice from the Monastery


In reply to DBD::CSV::st execute failed: Can't locate object method "do_err" via package "SQL::Statement::Function::NumericEval" by Sandy_Bio_Perl

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.