Hi Guys,
Using CASCADE can be a bit dangerous as there might be other tables,
functions, views etc. that will be dropped but they are not meant to be.
Try this:
DO
$$
BEGIN
IF NOT EXISTS(SELECT *
FROM information_schema.triggers
WHERE event_object_tabl
CREATE TRIGGER mycheck_trigger BEFORE INSERT OR UPDATE ON mytbl
FOR EACH ROW EXECUTE PROCEDURE mycheck_pkey();
aborts transaction if trigger already exists.
There in no CREATE OR REPLACE TRIGGER command in PostgreSQL
How to create trigger only when it does not exist ?
Andrus.
--
>> How to create trigger only when it does not exist ?
> DROP TRIGGER IF EXISTS...
>
> See:
>
> http://www.postgresql.org/docs/8.2/static/sql-droptrigger.html
Thank you.
This doc says that dropping trigger drops depending objects also.
Which objects depend on the user-defined trigger so that the
"Rodrigo De León" <[EMAIL PROTECTED]> kirjutas sõnumis
news:[EMAIL PROTECTED]
> On May 26, 5:58 pm, "Andrus" <[EMAIL PROTECTED]> wrote:
>> Thank you.
>> This doc says that dropping trigger drops depending objects also.
>
> Only if you use CASCADE (default is RESTRICT).
>
If I do not use CASCADE
On May 26, 5:58 pm, "Andrus" <[EMAIL PROTECTED]> wrote:
> Thank you.
> This doc says that dropping trigger drops depending objects also.
Only if you use CASCADE (default is RESTRICT).
---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster
Andrus ha escrito:
> CREATE TRIGGER mycheck_trigger BEFORE INSERT OR UPDATE ON mytbl
> FOR EACH ROW EXECUTE PROCEDURE mycheck_pkey();
>
> aborts transaction if trigger already exists.
>
> There in no CREATE OR REPLACE TRIGGER command in PostgreSQL
>
> How to create trigger only when it does not