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

Is there a way given an Ima::DBI object to ask it to see the sql hiding behind the labels?
my @x = map { how_to_get_ima_sql_from_name($_)} @statement_names;
Thanks

water water everywhere

Replies are listed 'Best First'.
Re: Ima: see the sql?
by Corion (Patriarch) on Aug 24, 2004 at 21:03 UTC

    With Ima::DBI, the SQL statements are created when they are needed, and no earlier. So it's kinda hard to get at the SQL directly except through exercising the SQL statement. The closest and convenient enough thing I use is:

    DBI->trace(3)

    which spews out lots and lots of things that DBI does, but also everything up to where I get the error :). Ima::DBI does sprintf-interpolation for some stuff, this can easily bite you if you're doing LIKE '%foo' statements.

      oh well. thanks. I have a Ima object with some heavy  %s string interpolations, and wanted to send a copy of the actual sql to the debug log.

      thanks.

Re: Ima: see the sql?
by Fletch (Bishop) on Aug 25, 2004 at 02:31 UTC

    If you look in the TODO section of the documentation there's a note to the effect that the author wants "... to add debugging hooks". You might contact them and ask if they've made any progress and perhaps give them an idea of what you'd like to see as far as introspection / retrieving SQL (or as is often said, "patches welcome" :).

Re: Ima: see the sql?
by clscott (Friar) on Aug 25, 2004 at 18:44 UTC

    If you use DBI::Profile fomr the DBI distribution it will log the SQL for you along with some profiling data as you execute the queries.

    DBI::Profile produces much less output than DBI::Trace

    hth,

    --
    Clayton