Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private SQL1 As SQL
End Sub
Public Sub Initialize
' B4XPages.GetManager.LogEvents = True
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
#If B4J
Dim FileDir As String = File.DirApp
#Else
Dim FileDir As String = File.DirInternal
#End If
If File.Exists(FileDir, "data.db") = False Then
#If B4J
SQL1.InitializeSQLite(FileDir, "data.db", True)
#Else
SQL1.Initialize(FileDir, "data.db", True)
#End If
SQL1.AddNonQueryToBatch("CREATE TABLE tblClientGivenMedicine_Temp (rowid INTEGER PRIMARY KEY, JobDate TEXT, DrugID INTEGER, Notes TEXT, Created TEXT)", Null)
SQL1.AddNonQueryToBatch("INSERT INTO tblClientGivenMedicine_Temp (JobDate, DrugID, Notes, Created) VALUES (?, ?, ?, ?)", Array("12/20/2025", 11196, "-", DateTime.Now))
SQL1.AddNonQueryToBatch("INSERT INTO tblClientGivenMedicine_Temp (JobDate, DrugID, Notes, Created) VALUES (?, ?, ?, ?)", Array("12/20/2025", 11196, "-", DateTime.Now))
SQL1.AddNonQueryToBatch("INSERT INTO tblClientGivenMedicine_Temp (JobDate, DrugID, Notes, Created) VALUES (?, ?, ?, ?)", Array("12/20/2025", 11197, "-", DateTime.Now + 1))
SQL1.AddNonQueryToBatch("INSERT INTO tblClientGivenMedicine_Temp (JobDate, DrugID, Notes, Created) VALUES (?, ?, ?, ?)", Array("12/20/2025", 11197, "-", DateTime.Now + 2))
SQL1.AddNonQueryToBatch("INSERT INTO tblClientGivenMedicine_Temp (JobDate, DrugID, Notes, Created) VALUES (?, ?, ?, ?)", Array("12/20/2025", 11197, "-", DateTime.Now + 2))
SQL1.AddNonQueryToBatch("INSERT INTO tblClientGivenMedicine_Temp (JobDate, DrugID, Notes, Created) VALUES (?, ?, ?, ?)", Array("12/20/2025", 11197, "-", DateTime.Now + 2))
Dim SenderFilter As Object = SQL1.ExecNonQueryBatch("SQL")
Wait For (SenderFilter) SQL_NonQueryComplete (Success As Boolean)
Log("NonQuery: " & Success)
SQL1.ExecNonQuery2("UPDATE tblClientGivenMedicine_Temp SET Notes = ? WHERE rowid = (SELECT rowid FROM tblClientGivenMedicine_Temp WHERE JobDate = ? AND DrugID = ? ORDER BY Created DESC LIMIT 1)", Array As Object("555", "12/20/2025", 11197))
Dim res As ResultSet = SQL1.ExecQuery("SELECT * FROM tblClientGivenMedicine_Temp ORDER BY rowid")
Do While res.NextRow
Log($"${res.GetInt("rowid")}|${res.GetString("JobDate")}|${res.GetInt("DrugID")}|${res.GetString("Notes")}|${res.GetInt("Created")}"$)
Loop
res.Close
Else
'Delete the DB for next test
File.Delete(FileDir, "data.db")
End If
End Sub