[Tutor] Strange sqlite3 behavior
lang at tharin.com
Sat Jul 17 20:23:14 CEST 2010
On 07/17/2010 02:04 AM, Tim Golden wrote:
> On 17/07/2010 8:10 AM, Lang Hurst wrote:
>> I just had the weirdest issue with sqlite3. I was trying to update a
>> field to "Active". I have a little database of students and sometimes
>> they get sent to juvi, or just check out for a couple of months and show
>> back up. Anyway, I wanted to just have a field that had either "Active"
>> or "Inactive". I know, could go all boolean, but wanted to leave my
>> options open.
>> Anyway, my code was along the lines of
>> UPDATE students SET active="Inactive" where id="123456"
>> That would work, but
>> UPDATE students SET active="Active" where id="123456"
>> wouldn't. It wouldn't do anything, the field still held "Inactive".
> My guess -- without bothering to check the sqlite docs -- is that
> sqlite uses single quotes to delimit strings and double quotes to
> delimit column. Or at least that it can be set up to do that. If
> that is the case then "Active" is taken to refer to the column
> active and not to the string active. So you're just setting it
> to itself.
> Try it with 'Active' instead.
Yep, you were correct. Just ran that through sqlite3browser and any
phrase seems to work with either single or double quotes, EXCEPT
"Active". 'Active' works though. Good call. I worked around it, but
damn that was driving me crazy last night.
There are no stupid questions, just stupid people.
More information about the Tutor