Guillaume,
No it can't be wrong from the database's point of view, now what happens
in java is another problem
Here's how it works, in principle anyway.
The last value of each sequence which has been generated using nextval
is stored in the connections session memory.
so when you use the SAME connection to retrieve currval it will retrieve
that value.
If you get a different connection, or store it in a shared value in your
java then it doesn't work.
Dave
Guillaume Cottenceau wrote:
>Dave Cramer <pg 'at' fastcrypt.com> writes:
>
>
>
>>2)
>>allow the insert to go through
>>select currval('public."tblTable1_FieldID_seq"'::text)
>>and then use this to insert into table 2
>>
>>FYI currval does the "right" thing. It is guaranteed to be the value
>>your connection retrieved from the sequence.
>>
>>
>
>Which can be wrong in case of multithreaded applications without
>synchronization over the two requests, if I'm correct.
>
>
>
--
Dave Cramer
http://www.postgresintl.com
519 939 0336
ICQ#14675561