18

i want to create procedure with BL in its body. i find the same example in SQL but not in postgresql.

user3555572
  • 219
  • 2
  • 7
  • 2
    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) –  Jan 26 '15 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.*** http://www.postgresql.org/docs/current/static/sql-createtrigger.html – pozs Jan 26 '15 at 11:55
  • 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? – user3555572 Jan 26 '15 at 11:58
  • Again: what do you mean with "*in SQL*"? `SQL` is **just a query language**. But the bottom line is: you simply can't do that in Postgres. See the examples in the manual: http://www.postgresql.org/docs/current/static/plpgsql-trigger.html –  Jan 26 '15 at 12:02

2 Answers2

20

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

  1. Create a function in PostgreSQL with you BL
  2. Create a trigger and associate your function with this trigger.
M Faisal Hameed
  • 673
  • 1
  • 7
  • 25
6

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.

Pavel Stehule
  • 42,331
  • 5
  • 91
  • 94