Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jr0ka-0005Jv-4w for pgsql-general@arkaria.postgresql.org; Thu, 02 Jul 2020 15:03:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jr0kZ-000651-2X for pgsql-general@arkaria.postgresql.org; Thu, 02 Jul 2020 15:03:43 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jr0kY-00064u-Qp for pgsql-general@lists.postgresql.org; Thu, 02 Jul 2020 15:03:42 +0000 Received: from mailbackend.panix.com ([166.84.1.89]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jr0kV-0007hb-Lc for pgsql-general@lists.postgresql.org; Thu, 02 Jul 2020 15:03:41 +0000 Received: from panix2.panix.com (panix2.panix.com [166.84.1.2]) by mailbackend.panix.com (Postfix) with ESMTP id 49yLvY61KMzq7P for ; Thu, 2 Jul 2020 11:03:37 -0400 (EDT) Received: by panix2.panix.com (Postfix, from userid 17622) id 49yLvY5BCSz1ZWC; Thu, 2 Jul 2020 11:03:37 -0400 (EDT) Date: Thu, 2 Jul 2020 11:03:37 -0400 From: stan To: pgsql-general@lists.postgresql.org Subject: Catching errors with Perl DBI Message-ID: <20200702150337.GA18581@panix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Editor: gVim List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk How can I catch the errors generated whne I call an INSERT that violates a constraint? I have coded like this: my $sth = $dbh->prepare($stmt); my $rv = $sth->execute() or die $DBI::errstr; if ( $rv < 0 ) { print $DBI::errstr; } But, if the INSERT violates a constraint, it never gets the the evaluation of the $rv Is this a setting for the DBI? -- "They that would give up essential liberty for temporary safety deserve neither liberty nor safety." -- Benjamin Franklin