Thread: Values of fields in Rules

Values of fields in Rules

From
mito
Date:
Hi,

when i create rule(on insert) on view(select id, name from users), i 
will recieve values that were inserted in form of reference words 
new.id, new.name.

if i insert into users (id, name) values (null, null);
then new.id = null and new.name = null

if i insert into users (name) values (null);
then new.id = null and new.name = null

is there any way how to distinguish that id column wasnt explicitly named?



Re: Values of fields in Rules

From
mito
Date:
mito wrote:
> Hi,
> 
> when i create rule(on insert) on view(select id, name from users), i 
> will recieve values that were inserted in form of reference words 
> new.id, new.name.
> 
> if i insert into users (id, name) values (null, null);
> then new.id = null and new.name = null
> 
> if i insert into users (name) values (null);
> then new.id = null and new.name = null
> 
> is there any way how to distinguish that id column wasnt explicitly named?
> 

is there any way how to determinate in rule that null comes from 
explicit insert or from not naming column in insert statment


Re: Values of fields in Rules

From
Alvaro Herrera
Date:
mito escribió:

> is there any way how to determinate in rule that null comes from  
> explicit insert or from not naming column in insert statment

Not that I know of (and yes, this sucks).

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


Re: Values of fields in Rules

From
Bernd Helmle
Date:
--On Dienstag, Mai 05, 2009 20:25:54 -0400 Alvaro Herrera 
<alvherre@commandprompt.com> wrote:

> Not that I know of (and yes, this sucks).

But doesn't this also apply to triggers? I can't think of a reliable way to 
distinguish specified or unspecified fields in trigger functions as 
well....maybe fiddling with DEFAULT expressions.

--  Thanks
                   Bernd