pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedDBD::PG question
3+ messages / 2 participants
[nested] [flat]
* DBD::PG question
@ 2005-03-29 12:30 Frank Bax <fbax@sympatico.ca>
2005-03-29 17:54 ` Re: DBD::PG question Frank Bax <fbax@sympatico.ca>
2005-03-29 18:15 ` Re: DBD::PG question Greg Stark <gsstark@mit.edu>
0 siblings, 2 replies; 3+ messages in thread
From: Frank Bax @ 2005-03-29 12:30 UTC (permalink / raw)
To: pgsql-interfaces
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?
Frank
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: DBD::PG question
2005-03-29 12:30 DBD::PG question Frank Bax <fbax@sympatico.ca>
@ 2005-03-29 17:54 ` Frank Bax <fbax@sympatico.ca>
1 sibling, 0 replies; 3+ messages in thread
From: Frank Bax @ 2005-03-29 17:54 UTC (permalink / raw)
To: pgsql-interfaces
At 07:30 AM 3/29/05, Frank Bax wrote:
>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?
Thanks to Sean for suggesting I turn PrintError off/on:
http://search.cpan.org/~timb/DBI-1.48/DBI.pm#PrintError
Works as advertised - if only I'd found those docs before asking my question...
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: DBD::PG question
2005-03-29 12:30 DBD::PG question Frank Bax <fbax@sympatico.ca>
@ 2005-03-29 18:15 ` Greg Stark <gsstark@mit.edu>
1 sibling, 0 replies; 3+ messages in thread
From: Greg Stark @ 2005-03-29 18:15 UTC (permalink / raw)
To: Frank Bax <fbax@sympatico.ca>; +Cc: pgsql-interfaces
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
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2005-03-29 18:15 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-03-29 12:30 DBD::PG question Frank Bax <fbax@sympatico.ca>
2005-03-29 17:54 ` Frank Bax <fbax@sympatico.ca>
2005-03-29 18:15 ` Greg Stark <gsstark@mit.edu>
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