I'm sure this has been asked many times before, but Tim's reply here
prompted me to ask again.  Is there any way to access the DB version (as
per your example of get_info(18) below) from DBI.  For example as an
attribute of the database handle.  I've consulted the manual, but
couldn't find any reference to this.  We currently have a requirement to
support Oracle 7.3 and 9i, and in some cases the SQL we execute needs to
be  different (to take advantage of 9i features).  At present we obtain
the version ourselves by issuing :
"select banner from v$version", and parsing the appropriate bits out.  I
reckon it would be nicer (and presumably more portable) if the DBD layer
could expose this info.

Whadayareckon ?

-----Original Message-----
From: Tim Bunce [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, 4 December 2002 7:47 AM
To: David Wheeler
Cc: Jeff Boes; [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: DBD::Pg 1.20 uncompatible with Postgres 7.3?


On Tue, Dec 03, 2002 at 10:56:47AM -0800, David Wheeler wrote:
> On Tuesday, December 3, 2002, at 10:34  AM, Jeff Boes wrote:
> 
> >Nope, not quite:
> >
> >$ grep pg_ Pg.pm
> >
> >of Pg.pm 1.13 will show you that it relies on pg_database, pg_user, 
> >pg_class, pg_description, pg_attribute, pg_type, pg_index, 
> >pg_attrdef, and pg_relcheck.  All but the last one are still in 7.3. 
> >table_attributes is present in 1.13, and uses most of the listed 
> >tables.
> 
> Apparently, pg_relcheck was merged into another table in 7.3. Bummer
> for backwards compatibility, that. I'll try to figure out how the new 
> query should work in the next few days, but if anyone beats me to it, 
> patches welcome.
> 
> I guess this also means that DBD::Pg really needs to be changed to
> always detect the version of the database it connects to so that it
can 
> do the right thing. Tim, is there a DBI-standard way to story/provide 
> an RDBMS version number?

$version = get_info(18); # SQL_DBMS_VER

But note that the result needs to be formatted in a particular way: e.g.
06.50.0201

Google found http://www.4d.com/ACIDOC/CMU/CMU11922.HTM saying:

SQL_DBMS_VER (ODBC 1.0)

A character string indicating the version of the DBMS product accessed
by the driver. The version is of the form ##.##.####, where the first
two digits are the major version, the next two digits are the minor
version, and the last four digits are the release version. The driver
must render the DBMS product version in this form, but can also append
the DBMS product-specific version as well. For example, "04.01.0000 Rdb
4.1".

You might find this interesting:
http://www.geocrawler.com/archives/3/105/2001/1/0/5030630/

Driver authors are reminded that the DBI docs say:

Because some DBI methods make use of get_info(), drivers are strongly
encouraged to support I<at least> the following very minimal set of
information types to ensure the DBI itself works properly:
 
 Type  Name                        Example A     Example B
 ----  --------------------------  ------------  ------------
   17  SQL_DBMS_NAME               'ACCESS'      'Oracle'
   18  SQL_DBMS_VER                '03.50.0000'  '08.01.0721'
   29  SQL_IDENTIFIER_QUOTE_CHAR   '`'           '"'
   41  SQL_CATALOG_NAME_SEPARATOR  '.'           '@'
  114  SQL_CATALOG_LOCATION        1             2

Tim.

Reply via email to