'Non-UI application (console / server application)
#Region Project Attributes
#CommandLineArgs:
#MergeLibraries: True
' #AdditionalJar: sqlite-jdbc-3.43.0.0.jar
#AdditionalJar: sqlite-jdbc-3.40.0.0.jar
#End Region
Sub Process_Globals
Dim SQL As SQL
End Sub
Sub AppStart (Args() As String)
SQL.InitializeSQLite(File.DirApp, "mydb", True)
' Dim czas As String = "20230905115500 +0200" 'works
Dim czas As String = "20230905125000 +0200" 'works
' Dim czas As String = "20230905120000 +0200" 'works
Dim strQuery As String
strQuery="DROP TABLE IF EXISTS program" 'You don't have to drop the table every time. This is just for testing
SQL.ExecNonQuery(strQuery)
strQuery = $"
CREATE TABLE IF NOT EXISTS program (
ID INTEGER PRIMARY KEY,
channel TEXT,
title TEXT,
stop TEXT,
start TEXT)"$
SQL.ExecNonQuery(strQuery)
InsertRecords
strQuery = $"SELECT * FROM (SELECT channel, title, stop, start,
ROW_NUMBER() OVER (PARTITION BY channel ORDER BY channel) AS row_num
FROM program where stop > ?) subquery WHERE row_num <= ?"$
Dim rs As ResultSet = SQL.ExecQuery2(strQuery, Array As Object(czas, 5))
Do While rs.NextRow
Log($"${rs.GetString("stop")} ${rs.GetString("start")} ${rs.getlong("row_num")}"$)
Loop
rs.close
End Sub
Sub InsertRecords
Dim strQuery As String="INSERT OR IGNORE INTO program VALUES(?, ?, ?, ?, ?)"
SQL.ExecNonQuery2(strQuery, Array As Object (Null, "TravelXP eu", "Bliss", "20230905120000 +0200", "20230905113000 +0200"))
SQL.ExecNonQuery2(strQuery, Array As Object (Null, "TravelXP eu", "Best", "20230905124500 +0200", "20230905120000 +0200"))
SQL.ExecNonQuery2(strQuery, Array As Object (Null, "TravelXP eu", "Frodicted", "20230905124500 +0200", "20230905120000 +0200"))
SQL.ExecNonQuery2(strQuery, Array As Object (Null, "1+1 International", "Svit", "20230905140000 +0200", "20230905105000 +0200"))
SQL.ExecNonQuery2(strQuery, Array As Object (Null, "1+1 International", "Odnogo", "20230905143500 +0200", "20230905141000 +0200"))
strQuery = $"SELECT Count(*) AS cnt FROM program"$
Dim rs As ResultSet = SQL.ExecQuery(strQuery)
Log($"Records inserted in table: ${rs.GetLong("cnt"}"$))
rs.Close
End Sub