> You can solve this with DBD::CSV the same way you'd solve it with any > reasonably compliant SQL implementation - by putting delimiters around > identifiers that are not valid SQL identifiers. DBD::CSV uses the double > quote character as an identifier delimiter, so this will work: > > my $sql = qq{ SELECT * FROM info WHERE ip = "192.168.1.44" };
Er, except I mistakenly thought you were talking about a column name (an identifier) rather than a value. Values are delimited by single quote characters, not double quote characters, so the correct answer is this: my $sql = qq{ SELECT * FROM info WHERE ip = '192.168.1.44' }; To use delimited identifiers would be something like this: my $sql = qq{ SELECT * FROM "c:/foo/bar.csv" WHERE ip='192.168.1.44' }; -- Jeff > > Also it looks like you are connecting twice - the first connection in your > script will be ignored. > > -- > Jeff > > SELCT > > > -----Original Message----- > > From: Christian Krauße [mailto:[EMAIL PROTECTED] > > Sent: Saturday, April 7, 2007 10:42 PM > > To: dbi-users@perl.org > > Subject: Problem with DBI:CSV > > > > I want to use a given csv file as an Database. My problem ist the > > content, if I delete any "." (dot) or "-" everythings work as i would > > estimate. But in my case only: > > > > DBD::CSV::st fetchrow_array failed: Attempt to fetch row from a Non- > > SELECT statement [for Statement "SELECT * FROM info where > > IP=192.168.1.44"] at X:\Scripting\Perl\DBD-CSV\test1\test.pl line 13. > > > > appears. > > How could I solve this? > > > > ###content of my test.pl### > > use DBI; > > # $dbh=Database handle > > # $sth=Statement handle > > # > > $dbh = DBI->connect("DBI:CSV:f_dir=X:\\Scripting\\Perl\\DBD-CSV\ > > \test1") > > or die "Cannot connect: " . $DBI::errstr; > > > > $dbh = DBI->connect(qq{DBI:CSV:csv_sep_char=\\;}); > > $dbh->{'csv_tables'}->{'info'} = { 'file' => 'test_csv_tabelle'}; > > > > $sth = $dbh->prepare("SELECT * FROM info where IP=192.168.1.44"); > > $sth->execute($baz); > > while ( @row = $sth->fetchrow_array ) { > > print "@row\n"; > > } > > > > $sth->finish(); > > $dbh->disconnect(); > > ###END### > > ###content of my test_csv_tabelle### > > Date;Time;PC_Name;SN;MAC;IP;User;Switch;SW_IP;Port > > 1;2;3;4;5;6;7;8;9;10 > > 20070104;12:21;PC013;KXXXXXP; > > 000000000007;192.168.1.44;CK;S130;192.168.1.1;Fa0/17; > > ###END### > > > > >