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
Post a Comment