Re: Fwd: Trigger on VIEW not firing - Mailing list pgsql-general

From Ian Lawrence Barwick
Subject Re: Fwd: Trigger on VIEW not firing
Date
Msg-id CAB8KJ=idno99tHmN4_GiJ0W6m0vZXkcNhoPwtoRoF6m3vb+J5g@mail.gmail.com
Whole thread Raw
In response to Fwd: Trigger on VIEW not firing  (Massimo Costantini <massimo.costantini@gmail.com>)
Responses Re: Fwd: Trigger on VIEW not firing  (Massimo Costantini <massimo.costantini@gmail.com>)
List pgsql-general
2013/7/30 Massimo Costantini <massimo.costantini@gmail.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


pgsql-general by date:

Previous
From: Massimo Costantini
Date:
Subject: Fwd: Trigger on VIEW not firing
Next
From: Beena Emerson
Date:
Subject: Re: Fwd: Trigger on VIEW not firing