I am updating my table with the following statement:
UPDATE table SET percentage = percentage + ? WHERE id = ?
And the value that is being passed to the database may be positive and negative as well.
Is there a way to make sure that the percentage value is going to lie in the range of 0..100? Desirable to accomplish it, using only SQLite.
If it is less than 0 I want to make it 0; If it is more than 100 I want to make it 100.
I can have it done through my C code, but it would be better to have it done through SQLite.
Thank you in advance.
If you leave off the
whereclause, you’ll set percentages for the entire table, which is presumably what you want.However, it may be that percentages greater than 100 or less than zero are legitimate; I don’t know your problem domain.