20

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

4
  • 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) Commented Jan 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 Commented Jan 26, 2015 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? Commented Jan 26, 2015 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: postgresql.org/docs/current/static/plpgsql-trigger.html Commented Jan 26, 2015 at 12:02

2 Answers 2

21

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.
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.