Hmm, I have a view, its strictly a bunch of bit columns. Default value is 0=false, this view has a huge trigger on it.
I use the different columns to activate particular sections of the trigger code, within those I do inserts, deletes, updates etc. It was a design around not having stored procedures. Harold Wood & Meyuni Gani -----Original Message----- From: BareFeet <list....@tandb.com.au> Sent: Wednesday, June 03, 2009 6:21 PM To: General Discussion of SQLite Database <sqlite-users@sqlite.org> Subject: Re: [sqlite] how can we solve IF EXIST in SQLite Hi Harold, > SQL does have branching logic. > > (SELECT CASE > WHEN ((SELECT StoreId From History WHERE ItemId = NEW.ID LIMIT > 1) IS NULL) > THEN > 0 > ELSE > (SELECT StoreId FROM History WHERE ItemId = NEW.ID AND > UnitPrice = (SELECT MIN(UnitPrice) FROM HISTORY WHERE ItemId = > NEW.ID)) > END); > > i use it in my current project. Let me clarify. By "branching logic" I mean branching (eg if/then or loop) to perform an action such as update, insert, delete, create etc. The case/when/then construct is a function, not procedural branching (at least by my definition above). It will return different results depending on the test, but it can't be used to perform different actions based on the test. > you could modify this to meet the goal of insert x or update y. No, that won't work. You can't put an action (such as an update or an insert) inside a case statement. You can only put expressions (including select statements) within a case statement. Tom BareFeet -- Comparison of SQLite GUI applications: http://www.tandb.com.au/sqlite/compare/?ml _______________________________________________ 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