I need to compare to Oracle versions and decide which is newer/greater. Since the versions are 5 octets, I can't use the Version datatype. Does anyone have any recommendations?
Version 1: 11.1.0.2.0
Version 2: 11.2.0.3.0
Printable View
I need to compare to Oracle versions and decide which is newer/greater. Since the versions are 5 octets, I can't use the Version datatype. Does anyone have any recommendations?
Version 1: 11.1.0.2.0
Version 2: 11.2.0.3.0
In your case, since you're certain that each version will always have 5 octets in them, you need to write a nice function.
In this function, you must
a) split the strings with a .
b) compare the lists for each element.
c) if they are both equal, then go to the next element.
d) the element with the higher value has the newer version.
You could write this function in any language of your choice.
That's what I ended up writing:
Dim Ver, NewVer, arrVer(), arrNewVer() As String
Dim blnVer, blnNewVer As Boolean
Ver = "11.2.0.3.0"
NewVer = "11.02.0.3.1"
arrVer = Ver.Split(".")
arrNewVer = NewVer.Split(".")
For z As Integer = 0 To 4
If arrVer(z) = arrNewVer(z) Then
'continue checking
ElseIf CInt(arrVer(z)) > CInt(arrNewVer(z)) Then
blnVer = True
z = 4
ElseIf CInt(arrVer(z)) < CInt(arrNewVer(z)) Then
blnNewVer = True
z = 4
End If
Next
If blnVer = True Then
Console.WriteLine(Ver & " is larger than " & NewVer)
ElseIf blnNewVer = True Then
Console.WriteLine(Ver & " is smaller than " & NewVer)
Else
Console.WriteLine(Ver & " is equal to " & NewVer)
End If
Console.WriteLine("Press enter to continue")
Dim x As String = Console.ReadLine