RE: dynamic field names in a function. - Mailing list pgsql-general

From Soma Interesting
Subject RE: dynamic field names in a function.
Date
Msg-id 5.0.2.1.0.20010330105415.02344b10@pop.telus.net
Whole thread Raw
In response to RE: dynamic field names in a function.  (Soma Interesting <dfunct@telus.net>)
Responses Re: dynamic field names in a function.
Re: dynamic field names in a function.
List pgsql-general
Please.

In the following, is there something I can do so that postgres will
evaluate NEW.qty to NEW.name, treating qty as a variable and evaluating it
before evaluating the field reference? At this time it errors on an INSERT
with: "record new has no field qty".

CREATE FUNCTION func_test() RETURNS opaque AS '
    DECLARE
        qty varchar(5);
    BEGIN

        qty := ''name'';
        NEW.qty := ''target'';
        return new;
    END;
' LANGUAGE 'plpgsql';

CREATE TRIGGER func_test_trigger BEFORE INSERT
    ON test FOR EACH ROW
    EXECUTE PROCEDURE func_test ();


pgsql-general by date:

Previous
From: "Mitch Vincent"
Date:
Subject: Re: Globally Unique IDs?
Next
From: "Mitch Vincent"
Date:
Subject: Re: Memory Tuning