Re: Trigger problem - Mailing list pgsql-general

From Jan Wieck
Subject Re: Trigger problem
Date
Msg-id 200112071805.fB7I5h402111@saturn.jw.home
Whole thread Raw
In response to Re: Trigger problem  (mordicus <mordicus@free.fr>)
List pgsql-general
mordicus wrote:
> Stephan Szabo wrote:
>
> > On Thu, 6 Dec 2001, mordicus wrote:
> >
> >> So, if i do
> >>
> >> insert into abreviations(smot,mot,abreviation,pays) select
> >> smot,mot,abreviation,pays from a;
> >>
> >> the Trigger is executed for each row ONLY after all rows have been
> >> inserted, so the
> >> "   id    := currval(''abr_id'');"
> >> in my trigger have false value (always the last value after 53000 insert
> >> ...)
> >
> > Wouldn't NEW.id give you the value you want rather than mucking with the
> > sequence value?
> >
>
> hum, not tested but i don't think because nextval('abr_id') is the default
> value of id.

    So what value do you want to have? If it is the value the NEW
    row has gotten when  it  was  inserted,  you'll  find  it  in
    NEW.id.  The  trigger  call  mechanism  doesn't know any more
    where that  value  was  coming  from,  it  simply  pulls  the
    inserted row and fires the trigger.


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck@Yahoo.com #



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


pgsql-general by date:

Previous
From: Ken
Date:
Subject: Re: Errors: Too many open files
Next
From: Andrew Gould
Date:
Subject: Re: When do I Vacuum ?