Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Hello Monks.

I am using DBI and the CSV driver DBD::CSV for manipulating the the CSV files. my SELECT query is not interpreting the way I want it ot.

e.g., consider following table called test.csv:

OS,RELEASE,VERSION Ubuntu,Warty,4 Ubuntu,Hoary,5 Ubuntu,Breezy,5 Fedora,Yarrow,1 Fedora,Tettnang,2 Fedora,Stentz,4

So, I want to list the version for Fedora Stentz which is "4".

I have written below query:

my $query = "SELECT VERSION from test.csv WHERE OS="Fedora" AND RELEAS +E="Stentz"; my $sth = $dbh->prepare ($query); $sth->execute;

However, I get below error:

DBD::CSV::st execute failed: No such column '"Fedora" AND RELEASE="Ste +ntz"' at /usr/local/lib/perl/5.10.1/DBI/DBD/SqlEngine.pm line 796

So, This means the use of "AND" clause is causing the problem. I have worked a little bit on Oracle DB and know that the above Query would work fine on Oracle DB.

however, I am not able to put "AND" clause to work in above query.

I hve referred the documnetion @ SQL::Statement::Syntax (which is used by DBD::CSV), however it doensn't talk much about the "AND" clause usage.

Could you help in correcting the query please.

-Thnaks.


In reply to DBD::CSV - SQL Syntax - "AND" clause is not working properly by slayedbylucifer

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!
  • 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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (9)
    As of 2015-07-03 06:56 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (48 votes), past polls