cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Burton <bur...@spinn3r.com>
Subject Re: IF NOT EXISTS on UPDATE statements?
Date Tue, 18 Nov 2014 00:20:12 GMT
Oh yes.  That will work because a value is already there. I’m talking if
the value does not exist. Otherwise I’d have to insert a null first.

On Mon, Nov 17, 2014 at 3:30 PM, DuyHai Doan <doanduyhai@gmail.com> wrote:

> Just tested with C* 2.1.1
>
> cqlsh:test> CREATE TABLE simple(id int PRIMARY KEY, val text);
> cqlsh:test> INSERT INTO simple (id) VALUES (1);
> cqlsh:test> SELECT * FROM simple ;
>
>  id | val
> ----+------
>   1 | null
>
> (1 rows)
>
> cqlsh:test> UPDATE simple SET val = 'new val' WHERE id=1 *IF val = null*;
>
>  [applied]
> -----------
>       True
>
> cqlsh:test> SELECT * FROM simple ;
>
>  id | val
> ----+---------
>   1 | new val
>
> (1 rows)
>
> On Tue, Nov 18, 2014 at 12:12 AM, Kevin Burton <burton@spinn3r.com> wrote:
>
>>
>> "you can still do IF on UPDATE though… but it’s not possible to do IF
>>> mycolumn IS NULL" --> If mycolumn = null should work
>>>
>>>
>> Alas.. it doesn’t :-/
>>
>> --
>>
>> Founder/CEO Spinn3r.com
>> Location: *San Francisco, CA*
>> blog: http://burtonator.wordpress.com
>> … or check out my Google+ profile
>> <https://plus.google.com/102718274791889610666/posts>
>> <http://spinn3r.com>
>>
>>
>


-- 

Founder/CEO Spinn3r.com
Location: *San Francisco, CA*
blog: http://burtonator.wordpress.com
… or check out my Google+ profile
<https://plus.google.com/102718274791889610666/posts>
<http://spinn3r.com>

Mime
View raw message