Sub Process_Globals
Dim MYSQLIP = "172.25.0.42" As String
Dim MYSQLDBNAME = "classicmodels" As String
Dim MYSQLPORT = "3306" As String
Dim MYSQLUSER = "user1" As String
Dim MySQLPASS = "pass1" As String
Dim MySQLConnection As MariaDBConnector
Dim StockValue As Double : StockValue = 0
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
MySQLConnection.Initialize(MYSQLIP,MYSQLDBNAME,MYSQLUSER, MySQLPASS,MYSQLPORT)
End If
'ExecQuery all result values returned as strings
MySQLConnection.ExecQuery("query","select * from products")
'Batch updates into a transaction
MySQLConnection.AddNonQueryToBatch("UPDATE products SET quantityInStock = 123 where productCode = 'S12_1099'")
MySQLConnection.AddNonQueryToBatch("UPDATE products SET buyPrice = 60 where productCode = 'S700_3167'")
MySQLConnection.ExecuteNonQueryBatch("updateproducts")
'ExecQuery2 all result values returned as native types
MySQLConnection.ExecQuery2("getstockvalue","select * from products")
'Will Cause an Error
MySQLConnection.ExecQuery("query","select * from product")
'Singl update
MySQLConnection.ExecNonQuery("updateSingle","UPDATE products SET MSRP = 82 where productCode = 'S700_3167'")
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub query_update(product As Map)
If product.ContainsKey("productName") Then
Log(product.get("productName"))
End If
End Sub
Sub query_complete(finished As Boolean)
End Sub
Sub query_error(trace As String)
Log(trace)
End Sub
Sub updateProducts_complete(UpdateCount As Int)
Log(UpdateCount)
End Sub
Sub updateProducts_error(trace As String)
Log(trace)
End Sub
Sub getstockvalue_update(product As Map)
Dim StockQTY As Int
Dim StockPrice As Double
StockPrice = product.get("buyPrice")
StockQTY = product.get("quantityInStock")
StockValue = StockValue + (StockPrice * StockQTY)
End Sub
Sub getstockvalue_complete(finished As Boolean)
Log(NumberFormat(StockValue,0,2))
End Sub
Sub getstockvalue_error(trace As String)
Log(trace)
End Sub
Sub updatesingle_error( Trace As String )
End Sub
Sub updatesingle_complete(updatecount As Int)
Log(updatecount)
End Sub