Sub MaxViaSQL () As Int
Dim SQL1 As SQL, Fname As String
Fname = Rnd(1000000, 99999999) + Rnd(674, 9999)
SQL1.Initialize(File.DirInternalCache, Fname, True)
SQL1.ExecNonQuery("DROP TABLE IF EXISTS tab1")
SQL1.ExecNonQuery("CREATE TABLE tab1 (sum NUMBER, id NUMBER)")
Dim a(2) As String
Dim s As String, b, d As Int
For i = 0 To lstSort.Size - 1
s = lstSort.Get(i)
'Log(s)
b = s.LastIndexOf("-")
a(1) = s.SubString(b + 1)
a(0) = s.SubString2(0,b)
SQL1.ExecNonQuery2("INSERT INTO tab1 VALUES (?,?)", Array As Object (a(0), a(1)))
If (i Mod 50) = 0 Then DoEvents
Next
Dim L As Int
Try
L = SQL1.ExecQuerySingleResult("SELECT id FROM tab1 ORDER BY sum DESC")
Catch
L = -1
End Try
lstSort.Clear
File.Delete(File.DirInternalCache, Fname)
Return L
End Sub