No, this is not possible in Postgres (btw: what do you mean with "example in SQL"? - triggers are different for every DBMS, "SQL" is just a query language, not a DBMS product)
user330315
–
user330315
2015-01-26 11:50:18 +00:00
CommentedJan 26, 2015 at 11:50
1
PostgreSQL only allows the execution of a user-defined function for the triggered action. The standard allows the execution of a number of other SQL commands, such as CREATE TABLE, as the triggered action. This limitation is not hard to work around by creating a user-defined function that executes the desired commands.postgresql.org/docs/current/static/sql-createtrigger.html
i mean i did same thing in sql but now am working in postgresql and am not able to do in postgresql and can't find example like that so is it possible?
Every RDBMS have their own SQL language. You can't create trigger in PostgreSQL as you can create in Oracle/MS SQL etc. In order to create trigger in PostgreSQL you have to
Create a function in PostgreSQL with you BL
Create a trigger and associate your function with this trigger.
Sign up to request clarification or add additional context in comments.
Comments
8
It is not possible - PostgreSQL doesn't support SQL triggers - every trigger needs a related trigger function. Other databases supports SQL triggers only, but not PostgreSQL.
SQLis just a query language. But the bottom line is: you simply can't do that in Postgres. See the examples in the manual: postgresql.org/docs/current/static/plpgsql-trigger.html