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

Reply via email to