On 10/31/2013 8:22 PM, Igor Korot wrote:
Hi, ALL,
In the CREATE TRIGGER can I use something like this:

CREATE TRIGGER foo AFTER INSERT
BEGIN
     IF foo.field1 IS NULL
              UPDATE foo SET field1 = <some_value>;
     ELSE
              UPDATE foo SET field1 = field1 + 1 WHERE field1 > new.<value>;
END;

My concern is if CREATE TRIGER will understand conditionals.

No, there is no IF statement in SQLite. There are other ways to do operations conditionally. I'd help you with the correct syntax, but I don't understand what your example is supposed to achieve?

When you say foo.field1, which row of table foo do you want the value to come from? When you say new.<value>, a value in which field of the newly inserted row is this supposed to refer to? Perhaps you could explain what you are trying to do in English, rather than making up some syntax that doesn't make sense.
--
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to