Steffen Goeldner wrote:
>
> Steffen Goeldner wrote:
> >
> > I think, all currently supported information types are
> > stable across most Oracle releases. Other types may
> > depend on a specific version, thus SQL_DBMS_VERSION is
> > a top entry in the TODO list. I guess OCIServerVersion
> > can help in obtaining the version number, however it
> > returns the complete banner. I hope I find a reliable
> > way to parse that string. Suggestions welcome!
>
> I collected some alternatives to retrieve SQL_DBMS_VERSION:
>
> select * from v$version;
>
> select * from PRODUCT_COMPONENT_VERSION;
>
> set serveroutput on
> declare
> v varchar2(255);
> c varchar2(255);
> begin
> dbms_utility.db_version( v, c );
> dbms_output.put_line( v );
> dbms_output.put_line( c );
> end;
> /
>
> select dbms_utility.port_string from dual;
>
> The attached file shows the results for Oracle8.
> Unfortunately, I have no Oracle7 available. Is anybody so kind
> and provides the results for Oracle7?
>
Looking at the results from Oracle8:
<http://www.xray.mpe.mpg.de/mailing-lists/dbi/2002-01/msg00525.html>
and Oracle7:
<http://www.xray.mpe.mpg.de/mailing-lists/dbi/2002-01/msg00728.html>
something like
SELECT version
FROM product_component_version
WHERE product LIKE 'Oracle%'
should be a quite portable way.
The attached patch shows a possible implementation.
For get_info(SQL_DBMS_VERSION), we could use something like
sprintf '%02d.%02d.%1d%1d%1d%1d', @{$dbh->{ora_server_version}}
Steffen
*** DBD-Oracle-1.12.orig/Oracle.pm Fri Aug 31 18:27:18 2001
--- Oracle.pm Fri Jan 25 11:37:32 2002
***************
*** 580,585 ****
--- 580,601 ----
return 1;
}
+ sub _server_version {
+ my $dbh = shift;
+ return $dbh->{ora_server_version} if defined $dbh->{ora_server_version};
+ $dbh->{ora_server_version} = [];
+ my $sth = $dbh->prepare(<<'SQL') or return [];
+ SELECT version
+ FROM product_component_version
+ WHERE product LIKE 'Oracle%'
+ SQL
+ $sth->execute or return [];
+ my $row = $sth->fetch or return [];
+ $dbh->{ora_server_version} = [ split /\./, $row->[0] ];
+ $sth->finish;
+ return $dbh->{ora_server_version};
+ }
+
} # end of package DBD::Oracle::db