Re: Fwd: Trigger on VIEW not firing

From: Ian Lawrence Barwick <barwick(at)gmail(dot)com>
To: Massimo Costantini <massimo(dot)costantini(at)gmail(dot)com>
Cc: PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Fwd: Trigger on VIEW not firing
Date: 2013-07-30 12:49:58
Message-ID: CAB8KJ=idno99tHmN4_GiJ0W6m0vZXkcNhoPwtoRoF6m3vb+J5g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgeu-general pgsql-general

2013/7/30 Massimo Costantini <massimo(dot)costantini(at)gmail(dot)com>:
>
> Hi,
>
> I have a problem with Triggers on VIEW:
>
> suppose I have:
>
> CREATE TABLE work (
> id integer NOT NULL,
> work TEXT,
> worktype TEXT
> );
>
> CREATE VIEW worksub AS SELECT FROM work WHERE worktype='subordinate';
>
>
> CREATE OR REPLACE FUNCTION wrk_view() RETURNS TRIGGER AS $wrk_tg$
> BEGIN
> RAISE NOTICE 'UPDATE VIEW FROM: % OPERATION: %',TG_TABLE_NAME,
> TG_OP;
> END;
> $wrk_tg$ LANGUAGE plpgsql;
>
> CREATE TRIGGER wrk_tg INSTEAD OF INSERT OR DELETE OR UPDATE ON worksub
> FOR EACH ROW EXECUTE PROCEDURE wrk_view();
>
> nothing appen when I insert row in work table.

The trigger is on the view "worksub", not the "work" table.

BTW the trigger function doesn't return anything, which will cause an error.
(Also the view definition is missing column definitions in the SELECT clause).

Regards

Ian Barwick

In response to

Responses

Browse pgeu-general by date

  From Date Subject
Next Message Beena Emerson 2013-07-30 12:55:40 Re: Fwd: Trigger on VIEW not firing
Previous Message Massimo Costantini 2013-07-30 12:40:49 Fwd: Trigger on VIEW not firing

Browse pgsql-general by date

  From Date Subject
Next Message Beena Emerson 2013-07-30 12:55:40 Re: Fwd: Trigger on VIEW not firing
Previous Message Massimo Costantini 2013-07-30 12:40:49 Fwd: Trigger on VIEW not firing