in reply to [SOLVED] Need advice how to diagnose the problem when syntax using MAX() is correct according to MySQL monitor, but errors out in DBI

Sorry for late reply. It needs some luck and time to load the reply form without timing out and then successfully submit it.

Apparently people are so focused on code examples so that only @LanX and @ysth's replies did not completely miss the question. Actually I regret having edited the original post to add the suspected code, because it distracted from the question. But when some of the most respected forum users all demand to see code, it is sometimes not easy not to cave in.


The answer turned out to be this:

First I tried to find a method to log all DBI requests.

So I found the DBI::Log module, which unfortunately turned out dysfunctional (exiting the application after logging the first USE). However, its documentation hinted at an alternative: DBI Trace.

With DBI Trace it was easy as snap to find the actual offending command and its precise location, which was a different one than originally suspected.

Thank you all!
  • Comment on Re: Need advice how to diagnose the problem when syntax using MAX() is correct according to MySQL monitor, but errors out in DBI

Replies are listed 'Best First'.
Re^2: Need advice how to diagnose the problem when syntax using MAX() is correct according to MySQL monitor, but errors out in DBI
by ysth (Canon) on Nov 23, 2025 at 17:21 UTC
    This represents years of experience of being shown everything but the actual problem code :). And lots of experience with misuse of ids, too. So often people want to use id to indicate temporal order and as hosed when it turns out a partial outage left some inserts out of order or when they want to add more historical data, I totally agree with afoken, wanting the max id usually means you're painting yourself into a corner.
Re^2: Need advice how to diagnose the problem when syntax using MAX() is correct according to MySQL monitor, but errors out in DBI
by 1nickt (Canon) on Nov 24, 2025 at 12:03 UTC

    Glad you found DBI_TRACE and solved your problem. What was the "offending command" in the end?


    The way forward always starts with a minimal test.
Re^2: Need advice how to diagnose the problem when syntax using MAX() is correct according to MySQL monitor, but errors out in DBI
by ikegami (Patriarch) on Nov 23, 2025 at 21:23 UTC

    You say we were wrong to ask for an actual demonstration of the problem, but then you say we were spot-on in identifying that something was missing from your description of the problem. Despite your ingratitude, I'm glad I directed you to collect more information about the problem, which led you to look elsewhere for the actual problem. Oh the irony of you saying I missed the point.

Re^2: Need advice how to diagnose the problem when syntax using MAX() is correct according to MySQL monitor, but errors out in DBI
by LanX (Saint) on Nov 24, 2025 at 10:23 UTC
    > so that only @LanX and @ysth's replies did not completely miss the question.

    Look, you literally said:

    > > Basically the code that fails is this:

    and many people spent a lot of time trying to help you "fixing" correct code.

    And now you complain that we missed the point? So, what was the question?

    I don't know what you expect from us, but mind-reading is probably better done at a circus.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    see Wikisyntax for the Monastery