I created table using this command :
CREATE TABLE projects( p_id integer primary key autoincrement, p_name text not null , p_desc text ,p_created_at datetime null , p_updated_at datetime null );
now i want to create a trigger on which the p_created_at and p_updated_at field will be updated,,,so i wrote
This is before insert query i wrote but gives me error
create trigger trigger_project before insert on projects
for each row begin
set new.p_created_at=now();
set new.p_updated_at=now();
end;
This gives me error
Error: near "set": syntax error
Any help is appreciated,, thnks
instead of now(); also tried datetime(‘now’);
but still no luck 🙁
According to the doc you can’t use just set, you need to write a statment, like
UPDATE myTable set column1 = value1