> my $sel1 = $dbh1->prepare("SELECT * FROM table1");
> my $sel1->execute();

 You need to remove the 'my' from the second line. It's declaring a new
$sel1, which masks the previous one (hence the first warning) and as it's a
new variable it'll be undef, but you're trying to call an execute method on
it (hence the final error).

-- 
Andy Hassall <[EMAIL PROTECTED]> / Space: disk usage analysis tool
<http://www.andyh.co.uk> / <http://www.andyhsoftware.co.uk/space> 

> -----Original Message-----
> From: Robert [mailto:[EMAIL PROTECTED] 
> Sent: 18 August 2004 18:51
> To: [EMAIL PROTECTED]
> Subject: DBD::CSV
> 
> Hi list,
> I can't figure out why this simple code is failing, please help.
> #!/usr/bin/perl -w
> use DBI;
> use strict;
> use DBI qw(:sql_types);
> DBI->trace( 1, 'dbitrace.log' );
> 
> my $dbh1 = DBI->connect("DBI:CSV:");
>     $dbh1->{'csv_tables'}->{'table1'} = {
>         'eol' => "\n",
>         'sep_char' => "|",
>         'quote_char' => undef,
>         'escape_char' => undef,
>         'file' => '/home/user/reports/report.csv',
>         'col_names' => ["hostname", "url", "username", "company"]
>     };
> my($hostname, $url, $username, $company);
> my $sel1 = $dbh1->prepare("SELECT * FROM table1");
> my $sel1->execute();
> while ($sel1->fetch) {
>         print("Found result row: hostname = $hostname, url = 
> $url, company = $company,  username = $username\n");
> }
> $dbh1->disconnect();
> "test4.pl" 27 lines, 698 characters 
> 
>  
> bash-2.03$ perl test4.pl
> "my" variable $sel1 masks earlier declaration in same scope 
> at test4.pl line 21.
> Can't call method "execute" on an undefined value at test4.pl line 21.
>  
> 
>  
> 
> 
> 
>               
> ---------------------------------
> Do you Yahoo!?
> New and Improved Yahoo! Mail - 100MB free storage!

Reply via email to