samedi 14 mars 2015

Incomplete SQL error in SQLite database

I've a SQLite script which initializes a DB (SQLite 3.8.2), created as follows:



sqlite3 -init database_creation.sql sample.db


The script file is like:



// Some `CREATE TABLE` statements

CREATE TRIGGER update_totalprice AFTER UPDATE
OF price, amount, boxes ON product
BEGIN UPDATE product SET totalprice = price * boxes * amount
WHERE idproduct = NEW.idproduct; END

// Some `INSERT` statements.


But it generates the following error:



Error: incomplete SQL: CREATE TRIGGER update_totalprice AFTER UPDATE
OF price, amount, boxes ON product
BEGIN UPDATE product SET totalprice = price * boxes * amount
WHERE idproduct = NEW.idproduct; END

// The rest of the file to the end.


I'm sure there're syntax errors nor creating the tables neither inserting the test rows, because if I comment the CREATE TRIGGER statement all works perfectly fine, and I don't find the syntax error either.


Aucun commentaire:

Enregistrer un commentaire