July 19th, 2011, 01:19 PM
Firebird DB_NAME() equivalent
I'm building some crystal reports to run against a number of our historical Firebird databases. They all have the same schema, so we will be running a number of the reports against multiple databases. We need some way to get the name of the database that the report is being run against. In MS SQL, it would just take a 'SELECT DB_NAME()'.
I've read through the system tables, and I couldn't find any place where the name of the database was being stored.
Is there any SQL funciton of command or SELECT statement that can be used to return the name of the database?
Thank you for any help that you might be able to offer,
July 19th, 2011, 02:18 PM
I think this should be available through
That should return exactly one row. One of the columns is the name of the database as far as I remember.
But I don't have a Firebird installation available right now.
July 19th, 2011, 02:30 PM
I had read in the language reference that it only had 'Description', 'Relation_ID', 'Security_Class', 'Character_Set_Name'. Just in case it was held in one of those fields, I ran the query and it returned:
Originally Posted by shammat
'Description' looked potentially helpful, but seeing as it's empty, I guess I'm out of luck there.
Thanks for the response, though.
July 20th, 2011, 02:52 AM
You can also try MON$DATABASE, it contains a bit more information. At least with my installation it actually shows the full filename of the database in the MON$DATABASE_NAME column.
Comments on this post
July 20th, 2011, 09:55 AM
Unfortunately, I don't see any system tables with the MON$ prefix, but I tried running the query anyhow... I got a 'table not found' error, which confirms it.
Originally Posted by shammat
I think that I might not be working with a Firebird database... I might be working with an interbase database (is there even a difference? I don't know). I've inherited these databases from an old RMS System, and I don't know how to check.
I'm thinking that I might just be out of luck. If someone has another idea, I'd love to hear it, but seeing as I'm not even sure that it's a Firebird database, I'm willing to call this one closed. Thanks to everyone who answered, I really appreciate your help.
July 21st, 2011, 08:40 AM
What is your FB version? MON$ tables are introduced in version 2.1
July 21st, 2011, 10:22 AM
After the little bit of digging that I was able to do, I beleive that I'm dealing with either Firebird 1.0 or Interbase 6.0. I have no idea how to differentiate between the two.
Originally Posted by mIRCata
July 22nd, 2011, 12:15 AM
I think i have a more simple one:
No matter how old FB or IB you are using, since you know the database file name when you connect to it. So no need to query it, but you can use the information from the connection parameters.
July 22nd, 2011, 10:06 AM
I'm using crystal reports to create the reports that we will be running. Currently, I just have the user's enter the name of the database, but I'm a bit pained to do it that way, as it's prone to human error. I've tried to work out how to get crystal reports to display the connection string on the report itself, but it's looking to be an impossibility.
Originally Posted by nagysz
I'm thinking that the only way to do it right would be for me to build a small c# application that micromanages the running of the reports. If I were to do that, then I could do as the above poster suggested, and just parse the DB Name from the connection string.
I was hoping to be able to avoid that with a simple query, but it's looking like the version of the Firebird databases that we have are too old to have the db Name stored locally.
Thanks to everyone who has posted. I'm really impressed by how active this forum is, and how helpful everyone has been.