Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: PLSQL code and different ORACLE versions
Not too sure about compile time but at run time, a decision can be made regarding Oracle version and decisions based around it.
I'm not sure if there is an 'official' way of obtaining it programatically but you can create a function based around v$version view to obtain the oracle version and use it in your code (see below)
You can have as much detail in your Oracle version (e.g 8, 8.0.1, 8.1 etc), just change the last number in the SUBSTR line in the c_version cursor accordingly.
I can think of other enhancements but haven't got the time to post them all!
In your code, just do something like
IF Oracle_Version = '8.0' THEN
.....
ELSIF Oracle_Version = '7.3' THEN
.....
END IF;
HTH,
Mark
CREATE OR REPLACE PROCEDURE Oracle_Version RETURN varchar2
v_info varchar2(1000); v_version varchar2(10); CURSOR c_version(v_info IN varchar2) IS SELECT SUBSTR(banner, INSTR(BANNER, 'Release', 1) + 8, 3) FROM v$version; CURSOR c_info IS SELECT banner FROM v$version;
BEGIN
-- -- Get version info from data dictionary --
-- -- Extract Oracle Version --
OPEN c_version(v_info);
FETCH c_version INTO v_version;
CLOSE c_version;
RETURN v_version;
END Oracle_Version;
Steffen Nicolai <nci_at_ast.iitb.fhg.de> wrote in message news:<3B4E94AB.672AAFB9_at_ast.iitb.fhg.de>...
> Hi,
>
> is there a way to develop PLSQL code for different ORACLE version and
> switch them during compile time (like #IFDEF preprocessor directives in
> C). One example is to use the FORALL statement in version 8.1.7 and the
> FOR ... LOOP in 8.0.5.
>
> TIA
>
> Nico
Received on Fri Jul 13 2001 - 05:50:25 CDT