Re: [SQL] nextval - Mailing list pgsql-sql

From Jerome ALET
Subject Re: [SQL] nextval
Date
Msg-id 356D7AF8.53B5376D@unice.fr
Whole thread Raw
In response to RE: [SQL] nextval  ("Jackson, DeJuan" <djackson@cpsgroup.com>)
List pgsql-sql
Jackson, DeJuan wrote:
> I wouldn't consider the results that Jerome is getting to be a bug.
> What is happening is that the RULE is inserting the new value into every
> row each time he inserts a new row.  A test to verify that would be to
> insert two rows then a select and see if the behavior is consistent with
> your previous assumptions.

OK, I'll try this tomorrow. I haven't tested this TEST :)

but when I read the doc I understand (I'm not English nor American)
that in the manual page:

   create rule rule_name
           as on event
             to object [where clause]
           do [instead]
           [action | nothing | [actions...]]

the WHERE is optional and that in:

           new or current can appear instead  of  an  instance
              variable whenever an instance variable is permissi-
              ble in SQL.

       The semantics of a rule is that at the time an  individual
       instance  is accessed, updated, inserted or deleted, there
       is a current instance (for retrieves, updates and deletes)
       and  a  new  instance  (for  updates and appends).  If the
       event specified in the on clause and the condition  speci-
       fied  in  the  where  clause  are  true  for  the  current
       instance, then the action part of the  rule  is  executed.
       First, however, values from fields in the current instance
       and/or the new instance are substituted for:
       current.attribute-name
       new.attribute-name

the rule should apply one tuple at a time.

maybe I was misunderstanding the manual page.

thanks all
Jerome ALET - alet@unice.fr - http://cortex.unice.fr/~jerome
Faculte de Medecine de Nice - http://noe.unice.fr - Tel: 04 93 37 76 30
28 Avenue de Valombrose - 06107 NICE Cedex 2 - FRANCE

pgsql-sql by date:

Previous
From: "Jackson, DeJuan"
Date:
Subject: RE: [SQL] nextval
Next
From: Dirk Lutzebaeck
Date:
Subject: How to insert columns into an array