Re: A VIEW mimicing a TABLE

From: William Leite Araújo <william(dot)bh(at)gmail(dot)com>
To: SunWuKung <Balazs(dot)Klein(at)t-online(dot)hu>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: A VIEW mimicing a TABLE
Date: 2006-12-14 13:58:55
Message-ID: bc63ad820612140558h4484fee0jede93362549c86bf@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

14 Dec 2006 02:45:12 -0800, SunWuKung <Balazs(dot)Klein(at)t-online(dot)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(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Vlad 2006-12-14 14:48:08 Re: creating an index with tablespace on a dedicated filesystem (postgresql 8.1.5)
Previous Message Markus Schiltknecht 2006-12-14 13:43:28 Re: Large Object to Bytea Conversion