X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 80473538D5 for ; Tue, 29 Mar 2005 19:15:39 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 38612-07 for ; Tue, 29 Mar 2005 18:15:29 +0000 (GMT) Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) by svr1.postgresql.org (Postfix) with ESMTP id 48711538BF for ; Tue, 29 Mar 2005 19:15:28 +0100 (BST) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1DGLFH-0001t4-00; Tue, 29 Mar 2005 13:15:19 -0500 To: Frank Bax Cc: pgsql-interfaces@postgresql.org Subject: Re: DBD::PG question References: <5.2.1.1.0.20050329072552.0581e2b0@pop6.sympatico.ca> In-Reply-To: <5.2.1.1.0.20050329072552.0581e2b0@pop6.sympatico.ca> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 29 Mar 2005 13:15:18 -0500 Message-ID: <878y46z5c9.fsf@stark.xeocode.com> Lines: 26 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.01 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/83 X-Sequence-Number: 5412 Frank Bax writes: > In a perl script using DBI and DBD:Pg, I need to drop/create a table: > $dbp->{RaiseError} = 0; > $dbp->do( "DROP TABLE $table" ); > $dbp->{RaiseError} = 1; > $dbp->do( "CREATE TABLE $table ..." ); > > If the table does not exist, the "DROP TABLE" produces an error message; but > script doesn't die because RaiseError was set to zero. Is there a way to > suppress this error message and then reset the change so an error in create > *is* seen? I think it looks something like this: { local($dbp->{RaiseError}) = 0; local($dbp->{PrintError}) = 0; $dbp->do( "DROP TABLE $table" ); } $dbp->do( "CREATE TABLE $table ..." ); -- greg