in reply to Re^2: DBD::Pg - $sth->execute($csv_var) ERROR
in thread DBD::Pg - $sth->execute($csv_var) ERROR


I'd definitely try the commit to see if that does the trick, but I'd also check to see if the statement had an error or not. If it *does*, then you can use the AutoCommit flag on the connect statement to avoid having to do a commit after every operation (though you might prefer the safety of handling commit yourself).

Since you could be getting an error from Pg, you'll want to check the error status of any command. An insert will fail if you violate a constraint on the table for example. So I tell DBI (on the connect statement) to check every statement and raise errors (using RaiseError and PrintError).


When your only tool is a hammer, all problems look like your thumb.

  • Comment on Re^3: DBD::Pg - $sth->execute($csv_var) ERROR

Replies are listed 'Best First'.
Re^4: DBD::Pg - $sth->execute($csv_var) ERROR
by perlygapes (Sexton) on Mar 18, 2020 at 03:54 UTC

    Hmmm...that's excellent exegesis.

    Whence I had thought I besought for errors to be caught then taught, I had:

    my $dbh = DBI->connect($DSN, $userid, $sesame, { AutoCommit => 0, RaiseError => 1, PrintError => 0 }) or die "Connection failed!\n" . $DBI::errstr;

    Hence I shall beseech for errors to be bleached and for Pg to teach me with:

    my $dbh = DBI->connect($DSN, $userid, $sesame, { AutoCommit => 1, RaiseError => 1, PrintError => 1 }) or die "Connection failed!\n" . $DBI::errstr;

    May thy code be blessed by the Profit of thy scripts.