http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_database

A simple "select database();" returns the current active database.

Does that not do what you want?


michael



On Mon, 22 Oct 2012, Meir Guttman wrote:

Date: Mon, 22 Oct 2012 19:19:24 +0200
From: Meir Guttman <m...@guttman.co.il>
To: dbi-users@perl.org
Subject: Retrieving the CURRENT default database name

Dear mavens,
My application interacts with a MySQL DBMS. There I am using subroutines and
packages that set the various attributes passed to the DBI "connect" method.
Also, I later switch databases based on a user's input by executing a "USE
'DB_name'" SQL statement.
What I am after is a way to debug my application and/or log a particular run
to verify what was actually selected as the "default database name" at any
given juncture. A bug there might be devastating....
Unfortunately, a real SQL maven says
(http://forums.mysql.com/read.php?10,571841,571848) that no SQL statement
exists to retrieve the currently set database.
I searched the web to find a way to do so, without success. Is there a DBI
(or DBD?) way to do so?
Regards
Meir

Reply via email to