Re: COPY table FROM STDIN
[prev]
[thread]
[next]
[Date index for 2004/07/23]
On Fri, 23 Jul 2004 09:14:52 -0400, Andy Harrison <aharrison@xxxxx.xxx> wrote:
> How can I do this from Class::DBI?
>
>
> > $ret = $dbh->func($line, 'putline');
All set. This little snippet I wrote does it just fine.
sub load_sql_file {
my ( $class, $table, $file_handle, $filename ) = @_;
$file_handle->close and open $file_handle, $filename ||
die "unable to reopen $filename: $!, $@\n";
my $dbh = $class->db_Main;
my $sth = $dbh->prepare( "COPY " . $table . " FROM STDIN" );
$sth->execute() or die "Unable to execute query: $! ",
$sth->errstr;
while ( <$file_handle> ) {
my $ret = $dbh->func( $_, 'putline' );
}
$dbh->disconnect;
}
--
Andy Harrison
|
|
Re: COPY table FROM STDIN
Andy Harrison 19:30 on 23 Jul 2004
|