7

Exist any Way to Determine the Version of Firebird SQL is running? using SQL or code (delphi, C++).

Bye

RRUZ
  • 134,889
  • 20
  • 356
  • 483

3 Answers3

16

If you want to find it via SQL you can use get_context to find the engine version it with the following:

SELECT rdb$get_context('SYSTEM', 'ENGINE_VERSION') 
             as version from rdb$database;

you can read more about it here firebird faq, but it requires Firebird 2.1 I believe.

Re0sless
  • 10,678
  • 6
  • 51
  • 66
  • Why did you use 2 single quotes in 'system' and 'engine_version' query fails that way, but with single quotes returns proper result – zz1433 Aug 08 '09 at 14:32
  • 1
    @Re0sless: Given that this will bomb for all versions before FB 2.1, isn't that cheating? Would you call a Vista-only API function and catch the possible crashes only to find out what Windows version the program runs on? The question was awfully vague, but this feels just wrong. – mghie Aug 08 '09 at 17:30
  • I have installed Firebird 2.5. I get following error after issuing above command: *** Starting transaction... Preparing query: SELECT rdb$get_context('SYSTEM', 'ENGINE_VERSION') from rdb$database Error: *** IBPP::SQLException *** Context: Statement::Prepare( SELECT rdb$get_context('SYSTEM', 'ENGINE_VERSION') from rdb$database ) Message: isc_dsql_prepare failed SQL Message : -804 An error was found in the application program input parameters for the SQL statement. Engine Code : 335544569 Engine Message : Dynamic SQL Error SQL error code = -804 Function unknown RDB$GET_CONTEXT – truthseeker Aug 10 '12 at 07:36
2

Two things you can do:

  • Use the Services API to query the server version, the call is isc_service_query() with the isc_info_svc_server_version parameter. Your preferred Delphi component set should surface a method to wrap this API.
    For C++ there is for example IBPP which has IBPP::Service::GetVersion() to return the version string.
    What you get back with these is the same string that is shown in the control panel applet.

  • If you need to check whether certain features are available it may be enough (or even better) to execute statements against the system tables to check whether a given system relation or some field in that relation is available. If the ODS of the database is from an older version some features may not be supported, even though the server version is recent enough.
    The ODS version can also be queried via the API, use the isc_database_info() call.

mghie
  • 32,028
  • 6
  • 87
  • 129
  • You can also query the server version and the server version string using a regular connection instead of the Services API, using the isc_database_info function with the isc_info_version parameter (you can also query the ODS version with isc_database_info). Another way of getting version information could be the isc_version function. – reiniero Nov 07 '12 at 08:57
-1

May be you have FIBPlus ( http://www.devrace.com/en/fibplus/ ) ... it has all the tools and sources necessary to install, uninstall, start, stop Firebird/Interbase and also to get the version of the server and more. In any case, you can get the version from the client driver (fbclient.dll for Firebird). DelphiDabbler ( http://www.delphidabbler.com/software/verinfo/download ) has free sources that get file version of any DLL. You can easily use that.

volvox
  • 1,194
  • 6
  • 22
  • 29
  • The version of the client library has nothing to do with the version of the server, different versions can be mixed and matched easily. Even with a local server the client library may well have a different version. – mghie Aug 08 '09 at 07:35
  • OK - That i did not know. Looking at my actual GDS32.DLL i get: Translation = Anglais (États-Unis) - Windows 3.1 US (ANSI) / Multilingual CompanyName = Embarcadero Technologies, Inc. FileDescription = InterBase Server FileVersion = WI-V9.0.2.420 InternalName = InterBase LegalCopyright = Copyright (c) 1986 - 2008 Embarcadero Technologies, Inc. ProductName = InterBase Server ProductVersion = 9.0.2.420 – volvox Aug 08 '09 at 12:56
  • For Firebird FBCLIENT.DLL: FileDescription = Firebird SQL Server FileVersion = WI-V2.1.2.18118 InternalName = Firebird LegalCopyright = All Copyright (c) retained by individual contributors - original code Copyright (c) 2000 Inprise Corporation ProductName = Firebird SQL Server ProductVersion = 2.1.2.18118 SpecialBuild = Firebird 2.1 – volvox Aug 08 '09 at 12:57
  • And this client library version makes only sense when the database is on localhost, otherwise the Firebird server could be for example 1.5.5 on Linux or some other *nix. Asking the server is the only way to be sure. – mghie Aug 08 '09 at 13:05