mike wrote:
> Anyone got any any idea what is happening here
> 
> $dbh=DBI->connect("dbi:Pg:dbname=data_cc",$user,$pw);
> $dump_dir='/home/data_cc/dump';
> @names=$dbh->tables();
> #$dbh->execute;
> #print @names;
> foreach $names(@names){
> if (substr($names,0,9) eq "public.tb")
> {
> $file1= "$dump_dir\/$names";
> $dbh->prepare("COPY $names TO ? WITH DELIMITER AS #");
> $dbh->bind_param(1,$file1);
> $dbh->execute();
> }
> }
> 
> results in output
> 
> 
> [Mon Mar 14 17:30:10 2005] [error] [client 127.0.0.1] Can't locate
> object method "bind_param" via package "DBI::db" at /home/www/cgi-
> bin/dump_all.pl line 25.

bind_param and execute are *statement* handle method, and you're applying
them
to a *database* handle. You need to save the return value from prepare()
and call bind_param() and execute() on that.

Or, you can combine the prepare/bind/execute all into one call to do():

   $dbh->do("COPY $names TO ? WITH DELIMITER AS #", undef, $file);

> 
> confused - it seems to be losing the connection to the db

No, the error message is a Perl error telling you that the package
that $dbh belongs to (DBI::db) doesn't have or inherit a method called
"bind_param".

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to