| From: | "Karen Hill" <karen_hill22(at)yahoo(dot)com> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | How do I use returning in a view? |
| Date: | 2007-02-17 17:06:57 |
| Message-ID: | 1171732017.451238.124710@p10g2000cwp.googlegroups.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
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?
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Scott Ribe | 2007-02-17 17:11:26 | Re: Small request re error message |
| Previous Message | Tom Lane | 2007-02-17 16:57:30 | Re: Anticipatory privileges |