Re: Trigger problem

From: Jan Wieck <janwieck(at)yahoo(dot)com>
To: mordicus(at)free(dot)fr
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Trigger problem
Date: 2001-12-07 18:05:42
Message-ID: 200112071805.fB7I5h402111@saturn.jw.home
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)Yahoo(dot)com #

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jan Wieck 2001-12-07 18:08:42 Re: Errors: Too many open files
Previous Message Roderick A. Anderson 2001-12-07 17:55:28 Re: When do I Vacuum ?