14 Dec 2006 02:45:12 -0800, SunWuKung <[EMAIL PROTECTED]>:


> 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 [EMAIL PROTECTED] so that your
       message can get through to the mailing list cleanly




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

Reply via email to