The SQL:2003 standard says you use syntax like this to do what you want:
CREATE TRIGGER Side_Insert AFTER INSERT ON Side BEGIN DECLARE LowDate DATE; SELECT MIN(Startdate) INTO LowDate FROM Basis; .... INSERT INTO BASIS (Name,Startdate) VALUES ("Trigger", LowDate); END;
You use 'declare' to declare a variable. Also, you only use 'set' when assigning the value of another variable or expression. You do not use 'set' to retrive the value of a query, but 'into' instead.
I don't know if SQLite supports this feature, though.
-- Darren Duncan
At 9:50 AM +0200 5/10/05, Philipp Knüsel wrote:
Hello SQLite Users
Is there a possibility to define variables within trigger definitions? I would like to to something like this (simplified example):
CREATE TRIGGER Side_Insert AFTER INSERT ON Side BEGIN SET LOWDATE = SELECT MIN(Startdate) FROM Basis; .... INSERT INTO BASIS (Name,Startdate) VALUES ("Trigger", LOWDATE); END;
I know, there is the possibility to do the same with SUBSELECTS,
but I'm looking for something easier/faster/more elegant than doing the same subselect several times.
(as my real example is more complicated)
Even if there is no possibility right know, I would probably suggest this as a feature for the future.
Thanks a lot!
Philipp