insertQuery method
Implementation
@override
Future<int?> insertQuery(String sql, FieldData fieldData) async {
if (_conn == null)
throw ArgumentError("connect() must be called before insertQuery");
try {
var result = await _conn!.query(sql, fieldData.getFieldDataValuesList);
return result.insertId;
} catch (e) {
if (getErrorCode(e.toString()) == 1062) {
throw SqlException(SqlExceptionEnum.DUPLICATE_ENTRY,
cause: e.toString());
} else if (getErrorCode(e.toString()) == 1146) {
throw SqlException(SqlExceptionEnum.TABLE_NOT_FOUND,
cause: e.toString());
} else if (e
.toString()
.startsWith("Bad state: Cannot write to socket, it is closed")) {
throw SqlException(SqlExceptionEnum.SOCKET_CLOSED,
cause: e.toString());
} else {
print("insertQuery:" + e.toString());
throw SqlException(SqlExceptionEnum.SQL_SYNTAX_ERROR,
cause: e.toString());
}
}
}