For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Beginners > November 2006 > Using DBI in a web context









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Using DBI in a web context
Robert Hicks

2006-11-08, 6:55 pm

I have a couple forms for an in-house application. The user fills out
the fields and then submits which update a back end Oracle database.

I have looked for examples but can't really find anything.

How is it best to catch errors when doing DBI stuff in web applications?
Wrap the insert "code" in an eval statement? Croak or die statements? I
am thinking eval because I can set autocommit to "off" and then do
rollbacks if $@ has an error.

Suggestions?

Robert
Steve Green

2006-11-14, 9:55 pm

Robert Hicks wrote:
> How is it best to catch errors when doing DBI stuff in web applications?
> Wrap the insert "code" in an eval statement? Croak or die statements? I
> am thinking eval because I can set autocommit to "off" and then do
> rollbacks if $@ has an error.
>


The PrintError, RaiseError, and HandleError attributes of a DBI handle
provide useful ways of dealing with errors that the database returns.

-- SG
Tyler Gee

2006-11-14, 9:55 pm

On 11/14/06, Steve Green <sgreen@well.com> wrote:
> Robert Hicks wrote:

You should probably avoid eval just because it spawns a separate perl
process each time, so if this is some code that is getting hit a lot,
you could really tax your server.
[color=darkred]
>
> The PrintError, RaiseError, and HandleError attributes of a DBI handle
> provide useful ways of dealing with errors that the database returns.


This is the standard way of detecting errors with DBI.

> -- SG
>
> --
> To unsubscribe, e-mail: beginners-cgi-unsubscribe@perl.org
> For additional commands, e-mail: beginners-cgi-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>



--
~Tyler
Shawn Hinchy

2006-11-14, 9:55 pm

That's funny, I just read about this today... See Tim Bunce's =20
tutorial from the Perl 3.0 Conference. I think it will answer some of =20
your questions...

Actually I couldn't find it from 99 but here is one from 2004.

http://search.cpan.org/src/TIMB/DBI..._2004/index.htm

Shawn
--------------------
Shawn Michael Hinchy
shawn@hinchy.net


Quoting Tyler Gee <gout@gmail.com>:

> On 11/14/06, Steve Green <sgreen@well.com> wrote:
>
> You should probably avoid eval just because it spawns a separate perl
> process each time, so if this is some code that is getting hit a lot,
> you could really tax your server.
>
>
> This is the standard way of detecting errors with DBI.
>
>
>
> --=20
> ~Tyler
>
> --=20
> To unsubscribe, e-mail: beginners-cgi-unsubscribe@perl.org
> For additional commands, e-mail: beginners-cgi-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>




Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com