Adds a Perl caller info to the SQL command


use DBIx::ShowCaller;
my $dbh = DBIx::ShowCaller->connect('dbi:Oracle:prod',
        'test', 'test', { 'RaiseError' => 1 });

# and follow as with normal DBI
$dbh->do('insert into jezek values (?)', {}, 45);
# will call (and log in V$SQL)
        /* script.pl at line 7 */
        insert into jezek values (:p1)


This module can be used instead of the DBI module. For each SQL command that is prepared (both using $dbh->prepare and via do, selectall_* and the like) it prepends a /* */ style comment containing information about file and line that called that prepare/selectall_*/other method. Thus it makes it easier to see where a particular SQL command came from.

Only database servers that log the whole SQL command (like Oracle or MySQL) can make reasonable use of this. Also, if you call the same SQL from different places of your code, the comment will be different and the SQL server won't be able to reuse parsed info. Consider the speed tradeoff here.




(c) 2000 Jan Pazdziora, jpx (dash) perl (at) adelton (dot) com, http://www.adelton.com/perl/

All rights reserved. This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See also