Re: A VIEW mimicing a TABLE - Mailing list pgsql-general

From William Leite Araújo
Subject Re: A VIEW mimicing a TABLE
Date
Msg-id bc63ad820612140558h4484fee0jede93362549c86bf@mail.gmail.com
Whole thread Raw
In response to Re: A VIEW mimicing a TABLE  ("SunWuKung" <Balazs.Klein@t-online.hu>)
List 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 by date:

Previous
From: "Shoaib Mir"
Date:
Subject: Re: error messages without schema name
Next
From: "Vanyel"
Date:
Subject: How to check constraints before call of simple_heap_insert()?