Firebird SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesFirebird SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 19th, 2011, 12:19 PM
chronicide chronicide is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2011
Posts: 5 chronicide User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #2  
Old July 19th, 2011, 01:18 PM
shammat shammat is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Oct 2003
Location: Germany
Posts: 2,685 shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 3 Days 19 h 56 m 37 sec
Reputation Power: 284
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.

Reply With Quote
  #3  
Old July 19th, 2011, 01:30 PM
chronicide chronicide is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2011
Posts: 5 chronicide User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
  #4  
Old July 20th, 2011, 01:52 AM
shammat shammat is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Oct 2003
Location: Germany
Posts: 2,685 shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 3 Days 19 h 56 m 37 sec
Reputation Power: 284
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
pabloj agrees!

Reply With Quote
  #5  
Old July 20th, 2011, 08:55 AM
chronicide chronicide is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2011
Posts: 5 chronicide User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #6  
Old July 21st, 2011, 07:40 AM
mIRCata mIRCata is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Location: Plovdiv. Bulgaria
Posts: 200 mIRCata User rank is Corporal (100 - 500 Reputation Level)mIRCata User rank is Corporal (100 - 500 Reputation Level)mIRCata User rank is Corporal (100 - 500 Reputation Level)mIRCata User rank is Corporal (100 - 500 Reputation Level) 
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

Reply With Quote
  #7  
Old July 21st, 2011, 09:22 AM
chronicide chronicide is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2011
Posts: 5 chronicide User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
  #8  
Old July 21st, 2011, 11:15 PM
nagysz nagysz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 200 nagysz User rank is Sergeant (500 - 2000 Reputation Level)nagysz User rank is Sergeant (500 - 2000 Reputation Level)nagysz User rank is Sergeant (500 - 2000 Reputation Level)nagysz User rank is Sergeant (500 - 2000 Reputation Level)nagysz User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 11 h 19 m 28 sec
Reputation Power: 13
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.

Reply With Quote
  #9  
Old July 22nd, 2011, 09:06 AM
chronicide chronicide is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2011
Posts: 5 chronicide User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > Firebird DB_NAME() equivalent

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap