I have the following setup which works great in version 8.3 but throws an error in 7.4:
CREATE TABLE atest1 ( id integer NOT NULL, descr text, CONSTRAINT atest1_pkey PRIMARY KEY (id) ); CREATE OR REPLACE FUNCTION test_trg() RETURNS "trigger" AS ' DECLARE any_rec wfsys.atest1; BEGIN any_rec.id := NEW.id; any_rec.descr := NEW.descr; select into any_rec * from dd_test(any_rec); --any_rec := dd_test(any_rec); RETURN any_rec; END; ' LANGUAGE 'plpgsql' VOLATILE; CREATE OR REPLACE FUNCTION dd_test(anyelement) RETURNS record AS ' DECLARE any_rec alias for $1; some_row record; BEGIN some_row := any_rec; if some_row.id < 0 then raise notice ''id is < 0!''; some_row.descr := ''some other value''; end if; RETURN some_row; END; ' LANGUAGE 'plpgsql' VOLATILE; CREATE TRIGGER trg_atest1 BEFORE INSERT ON atest1 FOR EACH ROW EXECUTE PROCEDURE test_trg(); Finally, firing the trigger like so: insert into wfsys.atest1 values(123, 'some text'); Gives the following error: ERROR: column "any_rec" does not exist CONTEXT: PL/pgSQL function "test_trg" line 7 at select into variables ********** Error ********** ERROR: column "any_rec" does not exist SQL state: 42703 Context: PL/pgSQL function "test_trg" line 7 at select into variables It works great on 8.3 (my dev server), but throws the error on the machine I am forced to work with, which is running version 7.4. I realize that polymorphic functions were pretty new in v7.4, is there a workaround or am I making a silly mistake? Or both? Incidentally, I get the same error when I change the polymorphic function's argument from "anyelement" to "wfsys.atest1" so it seems that it is occurring in the trigger function. Thanks for any help. Richard -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql