For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > March 2006 > Shutting off DBI warnings









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 Shutting off DBI warnings
Daniel Kaplan

2006-03-01, 6:56 pm

Hello,

I wanted to shut off the warnings produced by DBI so that if I call a DO to
execute an INSERT command, I won't get this:

DBD::mysql::db do failed: Duplicate entry '311135141' for key 1 at
local_create.pl line 45.

This way I can handle the error handling my own way by reading the return
values.

Is this possible?

Thanks


A. Sinan Unur

2006-03-01, 9:55 pm

"Daniel Kaplan" <NoSPam@NoSpam.com> wrote in
news:1141248706.329169@nntp.acecape.com:

> Hello,
>
> I wanted to shut off the warnings produced by DBI so that if I call a
> DO to execute an INSERT command, I won't get this:
>
> DBD::mysql::db do failed: Duplicate entry '311135141' for key 1 at
> local_create.pl line 45.
>
> This way I can handle the error handling my own way by reading the
> return values.
>
> Is this possible?


Have you considered reading the documentation?

See PrintWarn attribute in

http://search.cpan.org/~timb/DBI-1...._TO_ALL_HANDLES

Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/c...guidelines.html

xhoster@gmail.com

2006-03-01, 9:55 pm

"Daniel Kaplan" <NoSPam@NoSpam.com> wrote:
> Hello,
>
> I wanted to shut off the warnings produced by DBI so that if I call a DO
> to execute an INSERT command, I won't get this:
>
> DBD::mysql::db do failed: Duplicate entry '311135141' for key 1 at
> local_create.pl line 45.
>
> This way I can handle the error handling my own way by reading the return
> values.
>
> Is this possible?


Sure. What have you tried so far?

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
Jim Schneider

2006-03-09, 9:55 pm

A. Sinan Unar wrote:

>"Daniel Kaplan" <NoS...@NoSpam.com> wrote in
>news:1141248706.329169@nntp.acecape.com:
>
>
>
-<snip>-[color=darkred]
> Have you considered reading the documentation?
>
> See PrintWarn attribute in

-<snip>-

Just setting the "PrintWarn" attribute to zero would be ineffective in
this case, since the message originated from a database error, not a
warning. You would need to set both the "PrintError" and "RaiseError"
attributes to zero.

Be aware that not all DBI warning messages can be turned off without
resorting to ad-hockery (such as: $SIG{'__WARN__'} = sub {};)

harryfmudd [AT] comcast [DOT] net

2006-03-10, 6:56 pm

Jim Schneider wrote:
> A. Sinan Unar wrote:
>
>
>
> -<snip>-
>
>
> -<snip>-
>
> Just setting the "PrintWarn" attribute to zero would be ineffective in
> this case, since the message originated from a database error, not a
> warning. You would need to set both the "PrintError" and "RaiseError"
> attributes to zero.
>
> Be aware that not all DBI warning messages can be turned off without
> resorting to ad-hockery (such as: $SIG{'__WARN__'} = sub {};)
>


Also be aware that some of the settings were not in earlier versions of
DBI. For example, when PrintWarn was added it defaulted to 1, but the
old behaviour was equivalent to setting PrintWarn to 0. So if you wanted
the old behaviour, you had to check the version number and make the
PrintWarn setting if needed.

Tom Wyant
Sponsored Links







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

Copyright 2008 codecomments.com