Thanks for the suggestion of a temp table for storing intermediaire data, Igor.
Now DELETE TRANSACTION works fine with only SQL code! Sylvain -----Original Message----- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Igor Tandetnik Sent: Tuesday, January 26, 2010 6:23 PM To: sqlite-users@sqlite.org Subject: Re: [sqlite] Conditional insertion syntaxe in SQLite 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 _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users