Hi everyone,
This should be easy, but for some reason I can't figure it out.
I want to create a rule (or a trigger or whatever) so that when
data is inserted into a certain table, one column of the
newly inserted row is replaced with the result of a function.
In order words:
INSERT INTO foo (simple, special) VALUES ('a', 'b');
Should become:
INSERT INTO foo (simple, special) VALUES ('a', my_function('b'));
(Where 'special' is the column that needs to be replaced with
the dynamically generated data, and 'my_function' is the
function I want to be called: note that my_function needs to
be passed the data it is replacing).
Would someone be kind enough to write a rule for me which does
this? All the rules I've tried to write create infinite loops
(since the RULE is defined as ON INSERT, and its action is
doing an INSERT to the same table, which triggers the rule
again).
Thanks in advance,
Neil