From: Greg Stark <gsstark@mit.edu>
To: Frank Bax <fbax@sympatico.ca>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: DBD::PG question
Date: 29 Mar 2005 13:15:18 -0500
Message-ID: <878y46z5c9.fsf@stark.xeocode.com> (raw)
In-Reply-To: <5.2.1.1.0.20050329072552.0581e2b0@pop6.sympatico.ca>
References: <5.2.1.1.0.20050329072552.0581e2b0@pop6.sympatico.ca>
Frank Bax <fbax@sympatico.ca> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: gsstark@mit.edu, fbax@sympatico.ca
Subject: Re: DBD::PG question
In-Reply-To: <878y46z5c9.fsf@stark.xeocode.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox