19 messages in org.postgresql.pgsql-generalRE: dynamic field names in a function.
FromSent OnAttachments
Soma InterestingMar 29, 2001 2:38 pm 
Jeff EckermannMar 30, 2001 9:29 am 
Soma InterestingMar 30, 2001 10:06 am 
Soma InterestingMar 30, 2001 10:57 am 
Soma InterestingMar 30, 2001 1:58 pm 
Jeff EckermannMar 30, 2001 2:09 pm 
Soma InterestingMar 30, 2001 2:33 pm 
will trillichMar 30, 2001 3:46 pm 
Soma InterestingMar 30, 2001 4:38 pm 
will trillichMar 30, 2001 4:47 pm 
Soma InterestingMar 30, 2001 6:02 pm 
Eric G. MillerMar 30, 2001 7:29 pm 
Tom LaneMar 30, 2001 9:42 pm 
will trillichMar 30, 2001 10:04 pm 
will trillichMar 30, 2001 10:13 pm 
Tom LaneMar 31, 2001 4:57 pm 
will trillichApr 1, 2001 9:23 pm 
Tom LaneApr 1, 2001 11:27 pm 
Soma InterestingApr 3, 2001 1:23 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:RE: dynamic field names in a function.Actions...
From:Soma Interesting (dfu@telus.net)
Date:Mar 30, 2001 10:57:20 am
List:org.postgresql.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 ();