RE: dynamic field names in a function.

From: Soma Interesting <dfunct(at)telus(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: RE: dynamic field names in a function.
Date: 2001-03-30 18:57:42
Message-ID: 5.0.2.1.0.20010330105415.02344b10@pop.telus.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 ();

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruno Wolff III 2001-03-30 19:01:53 Re: Memory Tuning
Previous Message Mitch Vincent 2001-03-30 18:52:42 Re: Memory Tuning