Search notes:

Oracle: DBMS_DB_VERSION

dbms_db_version stores the Oracle version numbers which can be used for conditional compilation.

VERSION and RELEASE

Both, version and release are constant pls_integer values:
begin

  dbms_output.put_line('Version: ' || dbms_db_version.version);
  dbms_output.put_line('Release: ' || dbms_db_version.release);

end;
/

Constants

dbms_db_version defines a few boolean constants that can be used to determine if a given Oracle version or higher is present:
ver_le_9_1 Deprecated as of 19c
ver_le_9_2 Deprecated as of 19c
ver_le_9 Deprecated as of 19c
ver_le_10_1 Deprecated as of 19c
ver_le_10_2 Deprecated as of 19c
ver_le_10 Deprecated as of 19c
ver_le_11_1 Deprecated as of 19c
ver_le_11_2
ver_le_11
ver_le_12_1
ver_le_12_2
ver_le_12
ver_le_18
ver_le_19
etc…
For example, dbms_db_version.ver_le_10 is true when running on Version 10 or earlier.

Conditional compilation

The constants in dbms_db_version are static, so they can be used in Conditional Compilation.
create or replace procedure tq84_version_test
   authid definer
as begin

   $if dbms_db_version.ver_le_18 $then
       raise_application_error(-20800, 'Upgrade to a newer Oracle version');
   $end

   dbms_output.put_line('do stuff that is only possible with Oracle 18 or so');

end tq84_version_test;
/

See also

dbms_utility.db_version
Oracle DBMS PL/SQL packages
dbms_registry_basic.sql
Determine database versions

Index