delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback



Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi








Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (0)


Function to Determine Oracle Version NumberFormat this article printer-friendly!Bookmark function is only available for registered users!
GetOraVersion()
Product:
Delphi 3.x (or higher)
Category:
Database-SQL
Skill Level:
Scoring:
Last Update:
11/20/2002
Search Keys:
delphi delphi3000 article borland vcl code-snippet Oracle Version RDBMS
Times Scored:
2
Visits:
13081
Uploader: Mike Heydon
Company: EOH
Reference: mheydon@eoh.co.za
 
Question/Problem/Abstract:
This function gets the connected Oracle version. It returns the version info in 3 OUT parameters.

VerNum : double    eg.  7.23
VerStrShort : string   eg. '7.2.3.0.0'
VerStrLong : string   eg. 'Oracle7 Server Release 7.2.3.0.0 - Production Release'

I have tested it with Oracle 7.2 and 8.17. I assume it should work for the others (not too sure about Oracle 9 though). Any feedback and fixes for different versions would be appreciated.

The TQuery parameter that it recieves is a TQuery component that is connected to an open database connection.

Example :

var VNum : double;
     VShort : string;
     VLong : string;
begin
  GetOraVersion(MySql,VNum,VShort,VLong);
  Label1.Caption := FloatToStr(VNum);
  Label2.Caption := VShort;
  Label3.Caption := VLong;
end;
Answer:



procedure GetOraVersion(Query : TQuery;
                        out VerNum : double;
                        out VerStrShort : string;
                        out VerStrLong : string);
var sTmp : string;
    cKey : char;
    i : integer;
begin
  Query.SQL.Text := 'select banner from v$version ' +
                    'where banner like ' + QuotedStr('Oracle%');
  Query.Open;

  if not Query.Eof then
    VerStrLong := Query.Fields[0].AsString
  else begin
    // Don't know this version
    VerStrLong := '?';
    VerNum := 0.0;
    VerStrShort := '?.?.?.?';
  end;

  Query.Close;

  if VerStrLong <> '?' then begin
    cKey := VerStrLong[7];   // eg. Oracle7  or  Oracle8i
    VerStrLong[7] := 'X';   // Mask it out
    sTmp := copy(VerStrLong,pos(cKey,VerStrLong),1024);
    VerStrShort := copy(sTmp,1,pos(' ',sTmp) - 1);
    sTmp := copy(VerStrShort,1,pos('.',VerStrShort));

    for i := length(sTmp) + 1 to length(VerStrShort) do begin
      if VerStrShort[i] <> '.' then sTmp := sTmp + VerStrShort[i];
    end;

    VerNum := StrToFloat(sTmp);
    VerStrLong[7] := cKey;  // Put correct character back
  end;
end;






Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment













 
Sign up to consume product discounts for Bronze memberships !

read more


   


  Community Ad of
Hans Gulö
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)