Re: FW: help with serial - Mailing list pgsql-sql

From Richard Huxton
Subject Re: FW: help with serial
Date
Msg-id 42B69602.4050309@archonet.com
Whole thread Raw
In response to FW: help with serial  ("Luca Rasconi" <luca.rasconi@students.cefriel.it>)
List pgsql-sql
Luca Rasconi wrote:
>  
> CREATE OR REPLACE RULE r1 AS
>     ON INSERT TO TABLE_A DO  INSERT INTO TABLE_B (uid) 
>   VALUES ((new.uid));

> how is it possible, why in a table 37 and in the other 37 + 1?

This is almost certainly the "nextval() evaluated twice" issue that 
catches everyone out from time to time. Check the mailing-list archives 
for discussion - it's because the rule acts as a macro, duplicating the 
expression.

--  Richard Huxton  Archonet Ltd


pgsql-sql by date:

Previous
From: Richard Huxton
Date:
Subject: Re: info
Next
From: Din Adrian
Date:
Subject: Re: UPDATEABLE VIEWS ... Examples?