Is this possible to create one trigger for Insert and Update operations in SQLite? I mean, something like this:
CREATE TRIGGER dbo.TR_TableName_TriggerName
ON dbo.TableName
AFTER INSERT, UPDATE, DELETE
AS
BEGIN
SET NOCOUNT ON;
IF NOT EXISTS(SELECT * FROM INSERTED)
-- DELETE
PRINT 'DELETE';
ELSE
BEGIN
IF NOT EXISTS(SELECT * FROM DELETED)
-- INSERT
PRINT 'INSERT';
ELSE
-- UPDATE
PRINT 'UPDATE';
END
END;
It's for MS SQL i think, source: Insert Update trigger how to determine if insert or update
Edit: Is it possible to create also one trigger for more than one table?
No, the syntax graph for CREATE TRIGGER clearly shows that only one of INSERT, UPDATE or DELETE can be given.
It also shows that only one table can be given as a table to trigger on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With