From: | John McCawley <nospam(at)hardgeus(dot)com> |
---|---|
To: | "surabhi(dot)ahuja" <surabhi(dot)ahuja(at)iiitb(dot)ac(dot)in> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: regarding triggers |
Date: | 2006-01-10 14:51:19 |
Message-ID: | 43C3C9E7.8050706@hardgeus.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Foreign keys do not cascade deletions. If table y references table x on
column a, the attempt to delete records in x with dependent records in y
will yield an error. So the answer to that question is no, your trigger
won't get called because a) y doesn't get touched because that's not
what foreign keys do and b) an error is raised anyway
Regarding the usefulness of triggers...I tend to stay away from them. I
like to keep my data in my database and my logic in my application. I
try to relegate triggers to very simple things like timestamping
records. i.e. things that I won't later wonder "What in the hell is
going on???"
surabhi.ahuja wrote:
> is there an advantage of using a trigger? when the same job can be
> performed by a stored procedure?
>
> one more question is as follows:
> suppose i have a table x, with a primary attribute 'a'
>
> and i have a table y, with the primary attribute 'b', and a foreign
> key 'a'.
>
> suppose i say delete from x where a = '1',
>
> it means that not only the rows from x get deleted but also rows from
> y get deleted.
>
> now i have a trigger which is written for deletes taking place from
> the table y.
>
> however if i say delete from x where a = '1',
>
> will the trigger (mentioned above) still be called? (because delete
> are also taking place from the table y)
>
> thanks,
> regards
> Surabhi
>
From | Date | Subject | |
---|---|---|---|
Next Message | Jaime Casanova | 2006-01-10 14:51:25 | Re: regarding triggers |
Previous Message | John McCawley | 2006-01-10 14:06:51 | Re: Best programming language / connectivity for best performance |