Re: Null values detected as 0 value

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Null values detected as 0 value
Дата
Msg-id 25608.1290436987@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Null values detected as 0 value  (Vaduvoiu Tiberiu <vaduvoiutibi@yahoo.com>)
Ответы Re: Null values detected as 0 value  (Vaduvoiu Tiberiu <vaduvoiutibi@yahoo.com>)
Список pgsql-novice
Vaduvoiu Tiberiu <vaduvoiutibi@yahoo.com> writes:
> Weird stuff is happening to me today...I have a table and a view that has same fields as the table. The
table(tb_network)has a field((parent_network_id) which is fk to itself. The view has a rule create for itself:  
> CREATE OR REPLACE RULE "Network_insert_unconditional" AS
> ��� ON INSERT TO "view_network" DO INSTEAD� INSERT INTO tb_network (...,parent_network_id....)
> � VALUES (....new.net_id_parent...)� RETURNING zxt_networks.network_id;

> Problem is, when I perform an insert on the view like this:
> INSERT INTO view_network (... parent_network_id....)
> VALUES (....,NULL,....)

> I always get " insert or update on table "tb_network" violates foreign key constraint ..DETAIL: Key
(parent_network_id)=(0)is not present in table "tb_network". 

Well, you've omitted all the useful details, but this stuff is not
magic.  Either that ON INSERT rule is changing null to zero, or you
have a trigger on the table that is doing it, or there's something
wrong with the initial query (are you sure you put the null in the
column you thought you did?)

            regards, tom lane

В списке pgsql-novice по дате отправления:

Предыдущее
От: Vaduvoiu Tiberiu
Дата:
Сообщение: Null values detected as 0 value
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Could not open relation with OID (table partitioning issue?)