tags:

views:

23

answers:

1

Hi,

I have written this sqlite statement and I am getting syntax error:

update List SET number = (CASE WHEN number>=3 then number++ WHEN number=1 then 3 ELSE number END) WHERE listKey=3;

I keep on getting : SQL error: near "WHEN": syntax error

I tried various versions, adding braces at places and all, but can't figure out the error. Can anyone pls. help me with this.

Thanks in Advance, rs

+3  A: 

If SQLite uses "++" syntax, I've never seen it. Try then number + 1 instead.

Larry Lustig
What is "nextNumberInList"? Is it the number from the "next" row in the table? And what is the "next" row (SQL does not have any concept of default row order). I suggest you post a complete version of your question (including the table structure, sample input data, and sample desired output) in a separate question.
Larry Lustig