Hi guys,
I have an barcode app that using sqlite in memory to store temporary data. The declaration in main module
Initialize in Starter service
There are 2 module that use this sqlite, Module A & Module B.
Module B, scan the barcode & insert the result in table MEM_BRCD, and after scan finished call module A to display the data.
Sub to insert the scan data to table in Module B
Sub to call in module B after scan finished
Sub ScanResult in Module A
Here are the strange things :
1) Scan only one Barcode# for ex : 123, Sub ScanResult in module A runs OK
2) Scan more than one Barcode#, for ex : 123 & 234, and error raised at this line
Any hints, how to solve this error?
Thanks in advance.
I have an barcode app that using sqlite in memory to store temporary data. The declaration in main module
B4X:
Sub Process_Globals
Public SQLMem As SQL
End Sub
Initialize in Starter service
B4X:
Sub Service_Create
Main.SQLMem.Initialize("", ":memory:", True)
Main.SqlMem.ExecNonQuery("CREATE TABLE MEM_BRCD(ID int,BARCODE text,DSCP text,QTY int)")
End Sub
There are 2 module that use this sqlite, Module A & Module B.
Module B, scan the barcode & insert the result in table MEM_BRCD, and after scan finished call module A to display the data.
Sub to insert the scan data to table in Module B
B4X:
Sub BarcodeOk(Id as Int,Barcode As String,Dscp as String)
Main.SQLMem.ExecNonQuery2("insert into MEM_BRCD values (?,?,?,?)",Array As Object(Id,Barcode,Dscp,1))
End Sub
Sub to call in module B after scan finished
B4X:
Sub ScanFinished
If SubExists(Caller,"ScanResult") Then
CallSubDelayed(Caller,"ScanResult")
End If
Activity.Finish
End Sub
Sub ScanResult in Module A
B4X:
Sub ScanResult
Try
Private Cur As Cursor
Cur = Main.SQLMem.ExecQuery("select ID,BARCODE,DSCP,sum(QTY) as QTY from MEM_BRCD group by ID,BARCODE,DSCP")
For i = 0 To Cur.RowCount - 1
Cur.Position = i
Main.SQLMem.ExecNonQuery2("insert into MEM_M_FNGD_SO values (?,?,?,?,?)",Array As Object(Cur.GetInt("ID"),Cur.GetString("BARCODE"),Cur.GetString("DSCP"),Cur.GetInt("QTY"),0))
Cur.Close
Next
Cur.Close
Catch
Log(LastException)
End Try
End Sub
Here are the strange things :
1) Scan only one Barcode# for ex : 123, Sub ScanResult in module A runs OK
2) Scan more than one Barcode#, for ex : 123 & 234, and error raised at this line
B4X:
Cur = Main.SQLMem.ExecQuery("select ID,BARCODE,DSCP,sum(QTY) as QTY from MEM_BRCD group by ID,BARCODE,DSCP")
Any hints, how to solve this error?
Thanks in advance.