rule on insert with default values for new instance

From: Janning Vygen <vygen(at)planwerk6(dot)de>
To: "PostgreSQL-General" <pgsql-general(at)postgresql(dot)org>
Subject: rule on insert with default values for new instance
Date: 2001-06-19 10:50:56
Message-ID: 01061912505602.01139@janning
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

if i have a table and a rule like this

CREATE TABLE user (id SERIAL, name text);

CREATE RULE startaccount AS ON INSERT
TO user
DO INSERT INTO account (name) VALUES
(new.id, new.name);

(i didnt check the syntax, hope you still get the point)

i get problems because it seems to me that new.id is not defined at the
moment i do the insert. the default value seems not to be calculated at this
time.

How can i get around this?

im quite new to sql and mabye there is a misunderstanding of the rule feature.

please give me a hint.
thanks in advance for any help.

janning

does anybody know a good book/website like an SQL cookbook with many many
examples to learn from?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Enrico Mangano 2001-06-19 13:26:56 SET TRANSACTION ISOLATION LEVEL SERIALIZABLE on 7.0
Previous Message Penguin 2001-06-19 10:45:26 Re: front ends for postgres under linux