Tiberio, Sylvain <sylvain.tibe...@eads.com> wrote: > Is it possible to write something like that in SQL (for SQLite of > course!): > > If [toDeleteMin,toDeleteMax] is include in an existing range > Store the existing range value into min and max variables > Delete [Min,Max] > Create [Min,toDeleteMin-1] > Create [toDeleteMax+1,max] > endif
There are no variables, but you can use a temp table. Something like this: create temp table Vars(rangeid, existingMin, existingMax); insert into Vars select rowid, roomIdMin, roomIdMax from range where roomIdMin < toDeleteMin and roomIdMax > toDeleteMax; delete from range where rowid = (select rangeid from Vars); insert into range select 1, existingMin, toDeleteMin from Vars; insert into range select 1, toDeleteMax, existingMax from Vars; drop table Vars; (Edge conditions are left as an exercise for the reader, I'm pretty sure I got them wrong). -- Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users