rewriting values with before trigger
| От | Robert Treat |
|---|---|
| Тема | rewriting values with before trigger |
| Дата | |
| Msg-id | 1051201544.4753.522.camel@camel обсуждение исходный текст |
| Ответы |
Re: [SQL] rewriting values with before trigger
Re: rewriting values with before trigger |
| Список | pgsql-general |
Is there a way to use triggers to rewrite data before determining if the
data for that field is valid?
postgres=# create table foo (
postgres(# bar timestamptz
postgres(# );
CREATE
postgres=# create or replace function test() returns opaque as '
postgres'# begin
postgres'# NEW.bar := NULL;
postgres'# return NEW;
postgres'# end;
postgres'# ' language 'plpgsql';
CREATE
postgres=# create trigger baz before insert on foo for each row execute
procedure test();
CREATE
postgres=# insert into foo values (now());
INSERT 411474706 1
postgres=# select * from foo;
bar
-----
(1 row)
postgres=# insert into foo values ('');
ERROR: Bad timestamp external representation ''
Is there anyway to do be able to change the '' into NULL before data
validity is checked with a trigger?
(FWIW this is 7.2, if this would actually work in 7.3 please lmk)
TIA,
Robert Treat
В списке pgsql-general по дате отправления: