Mac OSX 10.3 - DBI:CSV - after select executes statement handle says rows !=0, but all values undefined
From: Thuan-Jin Kee (kee_at_wehi.EDU.AU)
Date: 11/29/04
- Previous message: Thuan-Jin Kee: "FIXED: Mac OSX 10.3 - DBI:CSV - automatically updating the database handle's tables hash after opening a file"
- Next in thread: Thuan-Jin Kee: "Update: Mac OSX 10.3 - DBI:CSV - after select undefined values in rows seems to have something to do with the eol character"
- Reply: Thuan-Jin Kee: "Update: Mac OSX 10.3 - DBI:CSV - after select undefined values in rows seems to have something to do with the eol character"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 29 Nov 2004 16:53:07 +1100 (EST) To: dbi-users@perl.org
Hi everyone,
I've got another newbie question -
I'm able to grab the correct number of rows out of the csv file no
problems now, but the actual values in the rows are blank.
If I have the following file
# this comment not part of the csv file
custID,family,given^M
1,adams,mortica^M
1,adams,gomez^M
1,golden,gollum^M
1,greedy,grover^M
#this comment not part of the csv file either
and the following code
#!/usr/bin/perl -Wall
use strict;
use DBI;
my($dbh, $sth);
my($key, @row);
$dbh = DBI->connect("DBI:CSV:f_dir=./")
or die "Cannot connect: " . $DBI::errstr;
$sth = $dbh->prepare("select custID,family,given from customer")
or die "Cannot prepare: " . $dbh->errstr();
$sth->execute() or die "Cannot execute: " . $sth->errstr();
print "number of rows found: ". $sth->rows;
while(@row = $sth->fetchrow_array())
{
print join("-",@row);
}
$sth->finish();
$dbh->disconnect() or die "Can't disconnect ". $dbh->errstr();
#end code that sort of works
I get the following output
$ ./selectcsvfile.pl
number of rows found: 5
Use of uninitialized value in join or string at ./selectcsvfile.pl line 19.
Use of uninitialized value in join or string at ./selectcsvfile.pl line 19.
-- Use of uninitialized value in join or string at ./selectcsvfile.pl line 19. Use of uninitialized value in join or string at ./selectcsvfile.pl line 19. -- Use of uninitialized value in join or string at ./selectcsvfile.pl line 19. Use of uninitialized value in join or string at ./selectcsvfile.pl line 19. -- Use of uninitialized value in join or string at ./selectcsvfile.pl line 19. Use of uninitialized value in join or string at ./selectcsvfile.pl line 19. -- Use of uninitialized value in join or string at ./selectcsvfile.pl line 19. Use of uninitialized value in join or string at ./selectcsvfile.pl line 19. -- end of output which says to me that I'm retrieving all five rows, and getting the right number of columns in each row. but each of the values in the actual array are undefined. To my eye, I can't tell the difference between my code and the code up on here http://ironbark.bendigo.latrobe.edu.au/subjects/int32we/lectures/w09.d/Lect18.html on the first example of the section called SELECT subtleties. Please tell me what I'm missing? Yours Jin
- Previous message: Thuan-Jin Kee: "FIXED: Mac OSX 10.3 - DBI:CSV - automatically updating the database handle's tables hash after opening a file"
- Next in thread: Thuan-Jin Kee: "Update: Mac OSX 10.3 - DBI:CSV - after select undefined values in rows seems to have something to do with the eol character"
- Reply: Thuan-Jin Kee: "Update: Mac OSX 10.3 - DBI:CSV - after select undefined values in rows seems to have something to do with the eol character"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|