| От | Andreas Fromm |
|---|---|
| Тема | Re: inserting via "on insert" rule |
| Дата | |
| Msg-id | 3F54AA21.5060302@physik.uni-erlangen.de обсуждение |
| Ответ на | Re: inserting via "on insert" rule (Peter Eisentraut <peter_e@gmx.net>) |
| Список | pgsql-general |
Peter Eisentraut wrote: >Andreas Fromm writes: > > > >>I was thinking of defining a view "users" over "persons" which would let >>me retrive the list of useres. But How would I implement the rule for >>insertiung users? I tryed the following but NEW is not known where I >>want to use it: >> >>CREATE VIEW users AS >> SELECT * FROM persons WHERE is_user(person.id) = TRUE; >> >>CREATE RULE insert_on_users AS ON INSERT >> TO users DO INSTEAD >> INSERT INTO persons SELECT * FROM NEW; >> >> > >You can write > >... DO INSTEAD INSERT INTO persons VALUES (NEW.col1, NEW.col2, ...); > > Yes, but what if I don't pass a certain col. Is the default value inserted instead? Or will the transaction fail because of a wrong number of columns?
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера