Shutting off DBI warnings

Shutting off DBI warnings

am 01.03.2006 22:31:46 von DFS

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

Re: Shutting off DBI warnings

am 02.03.2006 03:20:04 von 1usa

"Daniel Kaplan" 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.50/DBI.pm#ATTRIBUTES_COMM ON_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/clpmisc/clpmisc_guidelines .html

Re: Shutting off DBI warnings

am 02.03.2006 03:58:30 von xhoster

"Daniel Kaplan" 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

Re: Shutting off DBI warnings

am 10.03.2006 03:37:51 von Jim Schneider

A. Sinan Unar wrote:

>"Daniel Kaplan" 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:
--
> Have you considered reading the documentation?
>
> See PrintWarn attribute in
--

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 {};)

Re: Shutting off DBI warnings

am 10.03.2006 19:20:42 von unknown

Jim Schneider wrote:
> A. Sinan Unar wrote:
>
>
>>"Daniel Kaplan" 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:
>
> --
>
>>Have you considered reading the documentation?
>>
>>See PrintWarn attribute in
>
> --
>
> 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