-- Table: test
CREATE TABLE "test" (
"test1" varchar(10)
) WITH OIDS;
-- Function: laenge()
CREATE FUNCTION "laenge"() RETURNS "opaque" AS '
begin
if length(new.test1) > 10 then
new.test1 = substr(new.test1,1,9);
end if;
return new;
end
' LANGUAGE 'plpgsql';
-- Trigger: laenge_trig ON test
CREATE TRIGGER "laenge_trig" BEFORE INSERT OR UPDATE ON "test" FOR EACH ROW EXECUTE PROCEDURE laenge();
insert into test (test1) values ('0123456789012');
value too long for type character varying(10)
regards
Johann Zuschlag
zuschlag(at)online(dot)de