in sqlite, how to update a column to null conditionally -


in sqlite, how can update varchar column null if value has length 0, otherwise value.

in other words, this, using c-like syntax:

update t set c = (value.length() == 0 ? null : value) ...; 

thanks.

provided table schema has been defined allow null values in column following query should produce results looking for

update t set columnnamex = null length(columnnamex) = 0 

this enforced using trigger.

create trigger tnulltrigger after insert on t  each row begin   update t   set columnnamex = null   length(columnnamex) = 0 end; 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -