Reputation: 361
I want to increment useing a table with Counters. So i got the following table:
create table counterInt (MeterID int, DayStamp timestamp, NumberOfValues counter, Value1 counter, Value2 counter, qualityScore counter, PRIMARY KEY((MeterID), DayStamp))
Also i have a list of objects and I fill the object list and iterate through it
public void insertBasic(List<CSVMeter> meterList)
{
try
{
Connect();
var statement = session.Prepare("Update counterInt SET NumberOfValues = NumberOfValues + ?, Value1 = Value1 + ?, Value2 = Value2 + ?, QualityScore = QualityScore + ?, ID, DayStamp, ) VALUES (?,?,?,?,?,?)");
var tasks = new List<Task>();
foreach (CSVMeter meter in meterList)
{
var bind = statement.Bind( meter.NumberOfValues, meter.Value, meter.Value2, meter.qualityScore, meter.MeterID, meter.PeriodStart);
var resultSetFuture = session.ExecuteAsync(bind);
tasks.Add(resultSetFuture);
}
Task.WaitAll(tasks.ToArray());
CloseConnection();
}
catch (Exception ex)
{
throw ex;
}
}
this is my object in C#
public CSVMeter(int meterID, DateTime periodStart, double value, double value2, int numberOfValues, double qualityScore)
{//getters setters that kind of stuff nothing weird}
Why do i get the following error and how can i resolve it? Also, can i use the prepared statements like that in this example?
An unhandled exception of type 'Cassandra.SyntaxError' occurred in counterTest.exe Additional information: line 1:136 no viable alternative at input ',' (...= QualityScore + ?, ID[,]...)
Also side question: is it possible to increment with doubles instead of integer?
Upvotes: 0
Views: 236
Reputation: 448
As the error message tells you: you have a syntax error in your cql command.
For an UPDATE
command you should use a WHERE
clause and you should not use VALUE
clause.
Watch your query carefully, it looks like you merged an INSERT
and an UPDATE
command.
Upvotes: 1