Dim sql1 As SQL = pool.GetConnection
sql1.BeginTransaction
Try
sql1.ExecNonQuery2($"INSERT IGNORE INTO xxxx (id,a,b,c,d,e)
VALUES (?,?,?,?,?,?);"$, _
Array As Object(Null, MData.Get("a"), MData.Get("b"),MData.Get("c"), _
MData.Get("d"), MData.Get("e")))
Dim errcode As Int = 0
Dim errmsg As String = ""
Dim Cursor As ResultSet
Cursor = sql1.ExecQuery("SHOW WARNINGS LIMIT 1;") 'parameters are sanitized so we could expect just 1 warning
Do While Cursor.NextRow
errcode = Cursor.GetInt("Code") '1062 for duplicate key
errmsg = Cursor.GetString("Message")
Loop
risp.Put("err", errcode)
risp.Put("errmsg", errmsg)
sql1.TransactionSuccessful
Catch
risp.Put("err",-101)
risp.Put("errmsg", LastException.Message)
sql1.Rollback
End Try
If Cursor.IsInitialized Then Cursor.Close
sql1.Close