Skip site navigation (1) Skip section navigation (2)

Re: currval() within one statement

From: Richard Huxton <dev(at)archonet(dot)com>
To: silly_sad <sad(at)bankir(dot)ru>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: currval() within one statement
Date: 2008-01-22 12:18:47
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
silly_sad wrote:
> id default value is always set by the trigger before insert on each 
> table for each row.
> The particular subproblem is to
> insert one record into ttt1
> and then insert corresponding record into ttt,
> ___This is the place to use currval.

I'd be tempted to turn it the other way around and have an AFTER trigger 
that just uses as the value to put into "ttt".

The reason to use an AFTER trigger is that you know the value can't be 
changed at that point, whereas with a BEFORE trigger it might. In your 
case it doesn't matter, but it's probably a good idea to be consistent 
in these things.

   Richard Huxton
   Archonet Ltd

In response to

pgsql-sql by date

Next:From: Michael GlaesemannDate: 2008-01-22 12:42:20
Subject: Re: TIMESTAMP comparison problem
Previous:From: hubert depesz lubaczewskiDate: 2008-01-22 11:27:54
Subject: Re: currval() within one statement

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group