Question about v$version [message #624845] |
Fri, 26 September 2014 09:55 |
|
lott42_gmail
Messages: 146 Registered: June 2010
|
Senior Member |
|
|
In one of my apps, I have a procedure that wants to know what version of the database is the application executing. Using sql like
I get something like:
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for Solaris: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
but if I run this on a different DB
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for Solaris: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
I can tell that the first execution is a 10g db while the second is an 11g db.
All I really want to know in my procedure is am I running 10g or 11g
I wrote something like this to extract the info
select SUBSTR(banner, INSTR(banner, '.', 1, 1) - 2, 2) db_version
from (select banner from v$version where rownum = 1) data;
DB_VERSION
11
Is there a better way to extract out what DB version i'm running??
|
|
|
|
|
Re: Question about v$version [message #624849 is a reply to message #624845] |
Fri, 26 September 2014 10:14 |
|
Michel Cadot
Messages: 68645 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
DBMS_DB_VERSION is accessible to public so you can remove access to V$VERSION.
This package contains (among other things) 2 constants: VERSION and RELEASE, these are what you want:
SQL> select * from v$version where rownum=1;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
1 row selected.
SQL> exec dbms_output.put_line(dbms_db_version.version||'.'||dbms_db_version.release);
10.2
PL/SQL procedure successfully completed.
SQL> select * from v$version where rownum=1;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
1 row selected.
SQL> exec dbms_output.put_line(dbms_db_version.version||'.'||dbms_db_version.release);
11.2
PL/SQL procedure successfully completed.
[Updated on: Fri, 26 September 2014 11:00] Report message to a moderator
|
|
|
|
|
|