CREATE RULE ins_productionlog AS ON INSERT TO vwProductionlog DO
INSTEAD
(
INSERT INTO PRODUCTIONLOG
(machine_name,product_serial_id,production_time,product_number,id)
VALUES
(new.machine_name, new.product_serial_id,
new.production_time,new.product_number, DEFAULT) RETURNING
productionlog.machine_name, productionlog.product_serial_id,
productionlog.production_time,
productionlog.product_number, productionlog.id AS foreign_id;
INSERT INTO TTEST (name, id) VALUES (new.name,
vwProductionlog.foreign_id ) ;
);
I have an updateable view (using rules) that I'm trying to improve by
using 8.2's RETURNING feature to place the result of one insert into
the next. I want to be able to put the returning "productionlog.id AS
foreign_id" into table TTEST. Is that even possible just using
RULES? If it is, what would be the correct syntax?