Re: A VIEW mimicing a TABLE

Поиск
Список
Период
Сортировка
От William Leite Araújo
Тема Re: A VIEW mimicing a TABLE
Дата
Msg-id bc63ad820612140558h4484fee0jede93362549c86bf@mail.gmail.com
обсуждение исходный текст
Ответ на Re: A VIEW mimicing a TABLE  ("SunWuKung" <Balazs.Klein@t-online.hu>)
Список pgsql-general
14 Dec 2006 02:45:12 -0800, SunWuKung <Balazs.Klein@t-online.hu>:

> CREATE RULE new_entry AS ON INSERT to logview DO INSTEAD INSERT
>    (id,tm,info) VALUES (COALESCE(new.id,[default]),COALESCE(new.tm
> ,[default]),COALESCE( new.info,[default]));

what would [default] insert here?

     A constant, a function, anything you want. I have a function to create rules of insert an update on views that have the same columns that the tables that its represent. In this case, my [default] is the default value for the column of the table.
     COALESCE function only choose the second argument when the first is null. An alias to "IF $1 IS NULL THEN $2 ELSE $1".
 

the default of the view or the default of the underlying table?

B.


---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to majordomo@postgresql.org so that your
       message can get through to the mailing list cleanly



--
William Leite Araújo
Analista de Banco de Dados - QualiConsult

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

Предыдущее
От: "Shoaib Mir"
Дата:
Сообщение: Re: error messages without schema name
Следующее
От: "Vanyel"
Дата:
Сообщение: How to check constraints before call of simple_heap_insert()?