Re: trigger: NEW/OLD-error or nothing happens - Mailing list pgsql-general

From Knut Suebert
Subject Re: trigger: NEW/OLD-error or nothing happens
Date
Msg-id 20010708170836.B17727@cascal.vtb
Whole thread Raw
In response to Re: trigger: NEW/OLD-error or nothing happens  ("Joe Conway" <joseph.conway@home.com>)
Responses Re: trigger: NEW/OLD-error or nothing happens  (Jan Wieck <JanWieck@Yahoo.com>)
List pgsql-general
Joe Conway schrieb:

> OLD does not make sense on an insert because there is no "OLD" data for a
> brand new row. Similarly, there is no "NEW" data during a delete. See
> http://www.postgresql.org/idocs/index.php?plpgsql-trigger.html

Makes sense, thanks. And at the bottom of that page is a nice hint
regarding the trigger BEFORE/AFTER insert.

So I changed to BEFORE -- but still nothing happens

An exception for debugging:

    create function nac_viceversa() returns opaque as'
    declare
        x int4;
    begin
        x := nacmin(NEW.sport,NEW.dport)
        NEW.minport := x;
        NEW.maxport := nacmax(NEW.sport,NEW.dport);
        raise exception ''%'',x;
    return NEW;
    end;
    'language 'plpgsql';

    create trigger nac_update before insert or update on traf
    for each row execute procedure nac_viceversa();

the calculation works...

    ERROR:  110
    ERROR:  110
    ERROR:  110

... but is not written into the row -- even after removing the exception ;-)

     id   | ... | device | minport | maxport
    12151 | ... | eth0   |         |
    12152 | ... | eth0   |         |

Am I stupid?
Knut Sübert

pgsql-general by date:

Previous
From: ÀîÁ¢ÐÂ
Date:
Subject: Re: Re: index on a box
Next
From: "omid omoomi"
Date:
Subject: Re: Re: index on a box