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

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -

javascript - Restarting Supervisor and effect on FlaskSocketIO -

php - Mongodb connectivity error -