SQLite Forum

Error while executing query, no column with such name exists
Login
I am having challenge with AFTER DELETE trigger.
I created some tables and triggers, testing them, I discovered the triggers aren't working. Meanwhile I use triggers on MSSQL and MySQL successfully.


Example:

CREATE TABLE COMPANY(  
   ID INT PRIMARY KEY     NOT NULL,  
   NAME           TEXT    NOT NULL,  
   AGE            INT     NOT NULL,  
   ADDRESS        CHAR(50),  
   SALARY         REAL  
);  

CREATE TABLE AUDIT(  
    EMP_ID INT NOT NULL,  
    ENTRY_DATE TEXT NOT NULL  
);   

CREATE TRIGGER after_del  AFTER DELETE    
ON COMPANY  
BEGIN  
INSERT INTO AUDIT(EMP_ID, ENTRY_DATE) VALUES (new.ID, datetime('now'));  
END;  

I have populated the company table with records and tried deleting a record, but it tells me no COLUMN named ID exists.