Re: perl Pg module and result status

From: Thomas Good <tomg(at)admin(dot)nrnet(dot)org>
To: Fernán Agüero <fernan(at)iib(dot)unsam(dot)edu(dot)ar>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: perl Pg module and result status
Date: 2000-09-22 13:30:47
Message-ID: Pine.LNX.4.05.10009220908180.5568-100000@admin.nrnet.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 22 Sep 2000, [ISO-8859-1] Fernn Agero wrote:

> Hi folks!
>
> Thanks for the advice. Excuse my delay in replying: I've been filled with
> work.
>
> And yes, I was using the Pg module that comes with pgsql, and not the DBI:Pg
> one. Now I switched to DBI and is surprising how much cleaner code you get,
> particularly since the checks for errors are done by DBI (PrintErrors => 1,
> RaiseErrors => 1).

You may wish to turn off RaiseErrors...you can still get the dbi
errors by doing: $dbi = $DBI::errstr; Embed this in your query -
if (!defined $rv) ... $dbi = $DBI::errstr; and so on.

The reason to do this is that you can then write your own stderr and
include the dbi errstr...this is very handy if you want to beef up the
debugging output that gets dumped to the apache error_log (I use DBI
alongside CGI in perl scripts).

The problem with RaiseErrors is that it overwrites any stderr the
script is looking to dump to the error_log...just an FYI.

> I have yet to get into more depth with DBI but, as you said, I find it
> easier to get things done. Not to mention the possibility of moving from
> one RDMS to another and just changing a couple of lines in the scripts.

The author of DBI (Tim Bunce) has an excellent book published by Tim
O'Reilly called Programming The Perl DBI Interface.

Cheers,
Tom

--------------------------------------------------------------------
SVCMC - Center for Behavioral Health
--------------------------------------------------------------------
Thomas Good tomg@ { admin | q8 } .nrnet.org
IS Coordinator / DBA Phone: 718-354-5528
Fax: 718-354-5056
--------------------------------------------------------------------
Powered by: PostgreSQL s l a c k w a r e FreeBSD:
RDBMS |---------- linux The Power To Serve
--------------------------------------------------------------------

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Enrico Comini 2000-09-22 13:50:57 Triggers
Previous Message Papp Gyozo 2000-09-22 11:43:51 one more word about rules