Just another Perl shrine | |
PerlMonks |
Perl DBI: Overloading statement handleby sherab (Scribe) |
on Nov 08, 2010 at 16:23 UTC ( [id://870145]=perlquestion: print w/replies, xml ) | Need Help?? |
sherab has asked for the wisdom of the Perl Monks concerning the following question:
Hello monks,
I have a module that our company code uses to establish a database handle. It specifically checks to see which databases are available, etc.. example below...
Later we are establishing our statement handle and executing code.... example... So far, so textbook..... What we are now needing to do is to append comments to our MySQL strings. Specifically the user id info We can get that info by pulling out $ENV{USER} variable and the goal is to turn the SQL statement into one where the user id is is pre-pended to the statement... in our above example it needs to execute as ... /* userid:jwilkie */ select id from customer where handle="fred"; We set the statement handle in about a million different places in our code and prepending the user id on every single statement handle is not realistic. Since the database handle is established in new_dbh, is there a way once the database handle is established that when the statement handle is executed, that we then pre-pend this user info in the new_dbh subroutine? Definitely let me know if this isn't clear enough or if I can provide more info. The reason for this is so that we can get user id's in MySQL's slow query log. MySQL runs one user but we have users identifiable by their user id when they run scripts from the CLI.
Back to
Seekers of Perl Wisdom
|
|