Values of fields in Rules

Started by mitoalmost 17 years ago4 messageshackers
Jump to latest
#1mito
milos.orszag@gmail.com

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?

#2mito
milos.orszag@gmail.com
In reply to: mito (#1)
Re: Values of fields in Rules

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

#3Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: mito (#2)
Re: Values of fields in Rules

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

#4Bernd Helmle
mailings@oopsware.de
In reply to: Alvaro Herrera (#3)
Re: Values of fields in Rules

--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