insert into view - Mailing list pgsql-general

From Ben-Nes Michael
Subject insert into view
Date
Msg-id 00bb01c26d5f$ce76ad40$aa0f5ac2@canaan.co.il
Whole thread Raw
Responses Re: insert into view  ("Aasmund Midttun Godal" <postgresql@aasmund.com>)
List pgsql-general
Hi

im trying to insert into the following view and i have problem handeling the
serial type

CREATE TABLE a (field11 serial PRIMARY KEY,field12 integer);
CREATE TABLE b (field11 integer REFERENCES field11, field22 integer PRIMARY
KEY)

CREATE VIEW some_view AS
    SELECT * FROM a,b left join b using (field11);

CREATE RULE insert_into_view AS ON INSERT TO some_view DO INSTEAD (
 INSERT INTO a (field12) VALUES (NEW.field11);
 INSERT INTO b (field11, field22) VALUES (NEW.field11, NEW.field22);
);

now.

how do i tell him the second insert in the rule to use the new value of the
serial from the first insert ?

Thanks in advance


pgsql-general by date:

Previous
From: Curt Sampson
Date:
Subject: Re: [HACKERS] Performance while loading data and indexing
Next
From: "Aasmund Midttun Godal"
Date:
Subject: Re: insert into view