Public Sub GetRecsTable(Table As DBResult) As Map
Dim Mainmap As Map
Dim Submap, Colmap As Map
Mainmap.Initialize
Submap.Initialize
Colmap.Initialize
Dim i,j As Int
i = 0
j = 0
For Each col In Table.Columns.Keys
Colmap.Put(i, col)
i = i + 1
Next
'Log(" Column map: "&Colmap)
For Each row() As Object In Table.Rows
i = 0
j = j + 1
Submap.Initialize
For Each record As Object In row
Dim r As String
r = record
r = r.Replace("'"," ")
Submap.Put(Colmap.Get(i),r)
i = i + 1
Next
'Log("Submap Record number: "&j)
'Log(Submap)
Mainmap.Put(j, Submap)
Next
Return Mainmap
End Sub
Sub UpdateOps(Mainmap As Map)
If Mainmap.Size = 0 Then
Return
End If
DefCM.SQL1.ExecNonQuery("DROP TABLE IF EXISTS Emp")
DefCM.SQL1.ExecNonQuery("CREATE TABLE Emp (PK INTEGER, Employee_no TEXT, Pin TEXT, First_name TEXT,Last_name TEXT, Rule INTEGER,Email TEXT, Company_id INTEGER, terminal INTEGER, updated INTEGER)")
Dim i, j As Int
For i = 0 To Mainmap.Size - 1
Dim sb As StringBuilder
sb.Initialize
' Log(Mainmap.GetKeyAt(i))
' Log(Mainmap.GetValueAt(i))
Dim M As Map
M.Initialize
M = Mainmap.GetValueAt(i)
sb.Append("INSERT INTO Emp VALUES( ")
For j = 0 To M.Size - 1
sb.Append("'"&M.GetValueAt(j)&"'")
If (j < M.Size - 1) Then
sb.Append( ", ")
End If
Next
sb.Append( ")")
' Log(" sql: "&sb.ToString)
DefCM.SQL1.ExecNonQuery(sb.ToString)
Next
End Sub