Thread: query

query

From
"Aftab Alam"
Date:
<p>Hello,<p>I want to create a trigger in PostgresSQL <p><span class="921122105-18112005">In trigger, Before inserting
therecord, if data is already in the table, the trigger fire the mesaage that data is already there, and after that
triggerckeck for next insert statement.</span><p><span class="921122105-18112005"></span><span
class="921122105-18112005">Howcan I do this , </span>Please reply.<p>Regards, <p>_____ <p>Aftab Alam  

Re: query

From
"JuanCri"
Date:
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