Check out this easy way to find Oracle version information
Takeaway: The PL/SQL package DBMS_DB_VERSION supplies several useful constants that you can use in your code to determine the currently running version of Oracle. Bob Watkins explains how this package makes version checking easier.
When an application will be distributed to customers—or even to multiple sites within the same company—version issues may arise. If the program is designed to use features specific to a particular version of Oracle, it will fail when run on earlier versions.
One way to check for version information is to select from the dynamic performance view V$VERSION. This outputs a set of banner texts identifying the version and release level of various components of Oracle. However, it can be a chore to parse this output.
When Oracle 9i Release 2 was introduced, it contained a new PL/SQL package called DBMS_DB_VERSION that makes version checking easier. This package has no procedures or functions, only a series of useful constants that you can interrogate to determine the currently running version.
The two simplest constants in the package are VERSION and RELEASE. On a 10gR2 instance, executing the following at a SQL*Plus prompt will return the number 10:
SET SERVEROUT ON
EXEC DBMS_OUTPUT.PUT_LINE (DBMS_DB_VERSION.VERSION);
The other constants are booleans that indicate whether the currently running version is less than or equal to a specific cutoff. Instead of extracting the version and release and writing logic to check them, simply test the appropriate boolean:
BEGIN
IF (DBMS_DB_VERSION.VER_LE_9_2) THEN
DBMS_OUTPUT.PUT_LINE ('Oracle 10g is required.');
ELSE
DBMS_OUTPUT.PUT_LINE ('Version check successful.');
END IF;
END;
/
This feature was introduced primarily to support conditional compilation in PL/SQL. Based on these constants, you could have your PL/SQL code specify different data types or avoid using features not yet implemented.
Miss a tip?
Check out the Oracle archive, and catch up on our most recent Oracle tips.
TechRepublic's Oracle newsletter covers automating Oracle utilities, generating database alerts, solving directed graph problems, and more. Automatically subscribe today!
Bob Watkins (OCP, MCDBA, MCSE, MCT) is a computer professional with 25 years of experience as a technical trainer, consultant, and database administrator. Visit Bob's site.
Print/View all Posts Comments on this article
|
|
|
|
White Papers, Webcasts, and Downloads
- The Scalable Enterprise: VMware ESX Server on the Dell PowerEdge 6650 Dell This paper introduces the server virtualization software, VMware ESX ... Download Now
- Why Isn't Server Virtualization Saving Us More? A Few Small Changes May Dramatically Increase Your Efficiency VMware Ever wonder why your company isn't saving more from its server virtualization? Making a few small changes could dramatically increase your efficiency. Download Now
- Building the Virtualized Enterprise with VMware Iinfrastructure VMware VMware virtualization software has been adopted by over 120,000 enterprise ... Download Now
- Building the Virtualized Enterprise with VMware Infrastructure VMware This paper explains how adopting a virtual infrastructure -- comprised of server, storage, and networking virtualization technologies -- can help your organization build a sustainable competitive ... Download Now
- Five Steps to Determine When to Virtualize YourServers VMware Thinking of virtualizing the servers at your company? Use this step-by-step guide to determine when's the best time to make your big move. Download Now
Article Categories
- Security
- Security Solutions, IT Locksmith
- Networking and Communications
- E-mail Administration NetNote, Cisco Routers and Switches
- CIO and IT Management
- Project Management, CIO Issues, Strategies that Scale
- Desktops, Laptops & OS
- Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
- Data Management
- Oracle, SQL Server
- Servers
- Windows NT, Linux NetNote, Windows Server 2003
- Career Development
- Geek Trivia
- Software/Web Development
- Web Development Zone, Visual Basic, .NET





