The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Databases
> Firebird SQL Development
|
Firebird DB_NAME() equivalent
Discuss Firebird DB_NAME() equivalent in the Firebird SQL Development forum on Dev Shed. Firebird DB_NAME() equivalent Firebird SQL Development forum discussing administration, Firebird SQL syntax, or other Firebird SQL-related topics. Firebird is the evolution of Borland's Interbase product.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

July 19th, 2011, 12:19 PM
|
|
Registered User
|
|
Join Date: Jul 2011
Posts: 5
Time spent in forums: 2 h 50 m 34 sec
Reputation Power: 0
|
|
|
Firebird DB_NAME() equivalent
Hey everyone,
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,
- Scott
|

July 19th, 2011, 01:18 PM
|
|
Contributing User
|
|
Join Date: Oct 2003
Location: Germany
|
|
I think this should be available through
Code:
SELECT *
FROM RDB$DATABASE
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, 01:30 PM
|
|
Registered User
|
|
Join Date: Jul 2011
Posts: 5
Time spent in forums: 2 h 50 m 34 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by shammat I think this should be available through
Code:
SELECT *
FROM RDB$DATABASE
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. |
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:
'','245','','ISO_8859_1'
'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, 01:52 AM
|
|
Contributing User
|
|
Join Date: Oct 2003
Location: Germany
|
|
|
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.
|

July 20th, 2011, 08:55 AM
|
|
Registered User
|
|
Join Date: Jul 2011
Posts: 5
Time spent in forums: 2 h 50 m 34 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by shammat 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. |
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.
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.
- Scott
|

July 21st, 2011, 07:40 AM
|
|
Contributing User
|
|
Join Date: Sep 2006
Location: Plovdiv. Bulgaria
Posts: 200
  
Time spent in forums: 2 Days 6 h 50 m 14 sec
Reputation Power: 11
|
|
|
What is your FB version? MON$ tables are introduced in version 2.1
|

July 21st, 2011, 09:22 AM
|
|
Registered User
|
|
Join Date: Jul 2011
Posts: 5
Time spent in forums: 2 h 50 m 34 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by mIRCata What is your FB version? MON$ tables are introduced in version 2.1 |
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.
|

July 21st, 2011, 11:15 PM
|
|
|
|
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, 09:06 AM
|
|
Registered User
|
|
Join Date: Jul 2011
Posts: 5
Time spent in forums: 2 h 50 m 34 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by nagysz 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. |
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.
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.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|