rule on insert with default values for new instance

Поиск
Список
Период
Сортировка
От Janning Vygen
Тема rule on insert with default values for new instance
Дата
Msg-id 01061912505602.01139@janning
обсуждение исходный текст
Ответы Re: rule on insert with default values for new instance
Список 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?


В списке pgsql-general по дате отправления:

Предыдущее
От: "Richard Huxton"
Дата:
Сообщение: Re: front ends for postgres under linux
Следующее
От: Penguin
Дата:
Сообщение: Re: front ends for postgres under linux