| From: | Greg Stark <gsstark(at)mit(dot)edu> |
|---|---|
| To: | Frank Bax <fbax(at)sympatico(dot)ca> |
| Cc: | pgsql-interfaces(at)postgresql(dot)org |
| Subject: | Re: DBD::PG question |
| Date: | 2005-03-29 18:15:18 |
| Message-ID: | 878y46z5c9.fsf@stark.xeocode.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-interfaces |
Frank Bax <fbax(at)sympatico(dot)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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Hans Poo | 2005-03-29 18:22:55 | Fw: suscribe |
| Previous Message | Frank Bax | 2005-03-29 17:54:22 | Re: DBD::PG question |