Search Postgresql Archives

Re: A VIEW mimicing a TABLE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



14 Dec 2006 02:45:12 -0800, SunWuKung <Balazs.Klein@xxxxxxxxxxx>:

> 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@xxxxxxxxxxxxxx so that your
       message can get through to the mailing list cleanly



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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux