On Feb 4, 2008 6:23 AM, Kostas Chatzikokolakis <[EMAIL PROTECTED]> wrote:
> >> I'm using a dbi handle that is shared between many packages in my > >> code. Some package might do a "USE db_name" to change the current > >> database of the connection. Can I retrieve the current database name > >> from the handle, either from DBI or from the DBD::mysql driver > >> (without querying the server)? > > > > What's wrong with 'perldoc DBI'? > > > > What's the name attribute of a database handle documented as doing? > > > > Does it not work for you? > This was a bit churlish of me, but may I recommend reading http://www.catb.org/~esr/faqs/smart-questions.html which advises you on how to ask questions without incurring such ... ire. > > Hello Jonathan, thanks for your reply. > > From perldoc: > > > Name [...] > > Usually (and recommended to be) the same as the "dbi:DriverName:..." > string used to connect to > > the database, but with the leading "dbi:DriverName:" removed. > > So Name returns the dsn used to connect, it is not meant to be the > "current" database (it's not updated when changing database by doing > "USE <db-name>"). I want something that is dynamic, similar to doing a > "SELECT DATABASE()" query in mysql, but without doing an actual query. > Sorry if I wasn't clear enough in my previous mail. > OK - fair enough. With DBD::Informix the Name is the 'DSN' supplied at connection time. There's a separate ix_Database attribute (in the private namespace) that gives the current database name. If you can change databases while a connection is in progress, Name is unreliable (that's the case on DBD::Informix, though it takes some care to make a connection changeable). But I think you are dependent on driver properties -- different drivers do it differently. -- Jonathan Leffler <[EMAIL PROTECTED]> #include <disclaimer.h> Guardian of DBD::Informix - v2007.0914 - http://dbi.perl.org "Blessed are we who can laugh at ourselves, for we shall never cease to be amused."