Search Postgresql Archives

Re: trigger

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Aftab Alam schrieb:
I want to create a trigger in PostgresSQL

In trigger, Before inserting the record, if data is already in the table, the trigger fire the mesaage that data is already there, and after that trigger ckeck for next insert statement.

You write a function that returns the type "trigger" and checks whether the data is already there (i.e. by SELECTing INTO a variable the number of records with your given values and checking if the variable is >0). If it is, let it shout out your NOTICE and RETURN NULL; if it's not, RETURN NEW; Afterwards, you create the actual trigger BEFORE INSERT ON your table FOR EACH ROW and let it execute your recently written function :-)

Good luck,

Stefan Balzter

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux