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