http://www.perlmonks.org?node_id=1078636

joperocho has asked for the wisdom of the Perl Monks concerning the following question:

Anyway to disable SQL Warning from being printed in errstr? I've tried setting PrintWarn, Warn, PrintError to 0, yet sql warnings are still being set in errstr. Sample Warning: DBI Error: 513: IBMCLI DriverDB2/LINUXZ64 SQL0513W The SQL statement will modify an entire table or view. SQLSTATE=01504 Please advise. Thanks in advance.

Replies are listed 'Best First'.
Re: How to disable SQL Warning in DBI.pm
by runrig (Abbot) on Mar 17, 2014 at 17:48 UTC
      Unfortunately, specifying / trapping the code is a fix, but not the solution I'm looking for. I want to suppress all warning message from being printed in errstr.
        The docs list a connection attribute "db2_quiet_mode". Does that do anything?

        If PrintWarn doesn't work though, I'd report that as a bug.

Re: How to disable SQL Warning in DBI.pm
by mje (Curate) on Mar 18, 2014 at 08:39 UTC

    What version of DBI are you using? I ask because Changes in DBI 1.630 says "NOTE: This release enables PrintWarn by default regardless of $^W. Your applications may generate more log messages than before." May be there is a problem with that change.

      We are using DBI version 1.607, setting PrintWarn to 0, doesn't work.

        And your script uses -w?

        Please re-read mje's post, and/or try to upgrade to recent DBI (in a local folder) and see if that fixes your problem


        Enjoy, Have FUN! H.Merijn
Re: How to disable SQL Warning in DBI.pm
by runrig (Abbot) on Mar 18, 2014 at 15:44 UTC

    I'm a little confused by this statement:

    disable SQL Warning from being printed in errstr? I've tried setting PrintWarn, Warn, PrintError to 0, yet sql warnings are still being set in errstr.

    Do you mean that errstr is just being set and you are printing the contents of errstr, or that warnings are being printed with no explicit print statements on your part?

      errstr is being populated by SQL Warning messages.
        Then there is no problem with PrintWarn (at least it sounds like your problem has nothing to do with PrintWarn). You can change the behavior with HandleSetErr, but why are you printing errstr or even caring what is in errstr if there are no errors? The problem resolution seems like it should be "Don't print errstr if there are no errors detected".