ok, thank to all
On Tue, Jul 30, 2013 at 3:30 PM, Beena Emerson wrote:
> Hi again,
>
> IIUC you want to update the alarm table only when the speed limit is above
> 100. You cannot achieve it by the view and triggers you have written here
> because the trigger will be fired even for values < 100
Hi again,
IIUC you want to update the alarm table only when the speed limit is above
100. You cannot achieve it by the view and triggers you have written here
because the trigger will be fired even for values < 100
=# INSERT INTO speedv VALUES (1, 'test', 10);
INSERT 0 1
=# SELECT * FROM speedv;
It works fine if you insert into the view:
=# INSERT INTO speedv VALUES (1, 'test', 100);
INSERT 0 1
=# SELECT * FROM alarm;
name | id | type |init| fired | t_end | t_user
--++---++---+---+
test | 0 | SPEED | 201
Thisi is my real situation, can I do this:
CREATE TABLE alarm(
name text,
id integer,
type text,
init timestamp,
fired timestamp,
end timestamp,
user test
);
CREATE TABLE car (
id integer,
type text,
speed double
);
CREATE VIEW speedv AS SELECT * FROM car WHERE speed>100;
CREATE OR
The trigger is on the view and fires when you query the view:
# DELETE FROM worksub;
NOTICE: UPDATE VIEW FROM: worksub OPERATION: DELETE
ERROR: control reached end of trigger procedure without RETURN
CONTEXT: PL/pgSQL function wrk_view()
On Tue, Jul 30, 2013 at 6:10 PM, Massimo Costantini
2013/7/30 Massimo Costantini :
>
> 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 wr
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
RAIS