Question

Is there any universal way to get the deleted/inserted/updated rows in trigger? I want to create one trigger (I mean one pice of code in my application), which should work on Oracle, Sql Server and Postgres. Is it possible? I'm using odbc drivers to connect to different dbs.

It's working in SQL Server, but not in Oracle.

CREATE TRIGGER schema.trg_nameON schema.table_name
                FOR DELETE
                AS
                BEGIN
                    DECLARE @id BIGINT;

                    SELECT @id = d.ID
                    FROM deleted d

                    DELETE
                    FROM schema.table_name
                    WHERE TOP_ID = @id;
                END
Was it helpful?

Solution

no, each RDMS will have its own syntax. The syntax you used is a sql server syntax.

what do you mean by create trigger on the application? Please provide us with more info

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top