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

Hi Monks

I know how to create a bind statement with DBI

But what I want to investigate is the sql sent to the server after the binds have been filled.

How do I get this diagnostic please?????

Thanks,

Kevman

Replies are listed 'Best First'.
Re: DBI + Bind
by andye (Curate) on Jun 06, 2002 at 10:17 UTC

      Thanks Andy,

      That worked a treat...
      Only problem I have now is bind doesnt appear to
      work very well with NULLS in an update statement

      Anyone tried binding NULL values in an update???
      I ended up wrapping an ISNULL around loads of fields :(
      Not ideal......

      Kevman

        Thats Exactly the problem.

        I pass in an array to fill in all the bind variables

        Some of the array is undef (ie NULL).

        So when it reaches these it bombs out.

        The only cure I had was to look at whether a field was
        NULLABLE, and translate the code...

        Ie UPDATE TABLE
        SET ISNULL(field, "ZZZ") = ?

        Then translate the undefs to ZZZ.... Not pretty

        Kevman
        I'm not quite sure what you mean. Are you saying you pass undef as a bind variable and it doesn't fill in NULL? It should.
Re: DBI + Bind
by mpeppler (Vicar) on Jun 06, 2002 at 15:00 UTC
    This will depend on the DBD driver you use (although andye's suggestion to use DBI->trace() is a good one).

    I can tell you that for DBD::Sybase there is no way to get the SQL statement with the bound values, as that happens in the server (you could get that information at the server level by turning on auditing, but that's a whole different story).

    Michael