query
query
От:
"Aftab Alam" <aalam@tatashare.com>
Дата:
Hello,
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.
How can I do this , Please reply.
Regards,
_____
Aftab Alam
Re: query
От:
"JuanCri" <juancri@gmail.com>
Дата:
First, INSERT statements are 1 to 1 with table rows... (unless you use a insert/select). Second, if you want to probe that.. it is better to create an UNIQUE index.. isn't it? Ok, if that's not enough for you... you can create a trigger that perform a SELECT COUNT(*) with the criteria and if it's > 0, you rise an exception (sorry, I don't have access to a databae now to check the code). Juan C. Olivares www.juancri.com