ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris O'Connell" <oconn...@gorillachicago.com>
Subject RE: How to get the generated key from insert with Oracle
Date Fri, 09 May 2008 15:08:40 GMT
Argh... sometimes it is that easy.

Yep, two different sql plus sessions, the first will always get *it's*
correct value of sequence.currval, regardless of how many times another
session calls sequence.nextval.

Thanks,
Chris

-----Original Message-----
From: Clinton Begin [mailto:clinton.begin@gmail.com] 
Sent: Friday, May 09, 2008 9:43 AM
To: user-java@ibatis.apache.org
Subject: Re: How to get the generated key from insert with Oracle

Easy enough to test... open two sqlplus sessions and step through an
example...


Clinton

On Fri, May 9, 2008 at 8:12 AM, Chris O'Connell
<oconnell@gorillachicago.com> wrote:
> Thanks.  I had never heard this before.  Just to make sure we are talking
> about the same thing, I'm not concerned about the sequence returning the
> same value to two different people when the trigger is calling 'nextval'.
> I'm worried about the fact that two inserts could happen before my code
that
> tries to call "sequence.currvalue" can execute for the first insert and I
> end up with two difference insert actions that get the same value for
> "sequence.currvalue".
>
> It isn't that I don't believe you :) but this is counter to what I
*thought*
> I knew, so I'm trying to get a full understanding of what is going on.
>
> Thanks,
> Chris
>
> -----Original Message-----
> From: Larry Meadors [mailto:larry.meadors@gmail.com]
> Sent: Thursday, May 08, 2008 5:38 PM
> To: user-java@ibatis.apache.org
> Subject: Re: How to get the generated key from insert with Oracle
>
> Not with a sequence, I've been told that they are 'session' aware, so
> if you get id 123 in your session, no one else ever will.
>
> Larry
>
>
> On Thu, May 8, 2008 at 4:21 PM, Chris O'Connell
> <oconnell@gorillachicago.com> wrote:
>> Even if I am executing all of this inside a transaction, don't I still
> have
>>  concurrency issues with this approach?
>>
>>
>>
>>  -----Original Message-----
>>  From: Larry Meadors [mailto:larry.meadors@gmail.com]
>>  Sent: Thursday, May 08, 2008 5:12 PM
>>  To: user-java@ibatis.apache.org
>>  Subject: Re: How to get the generated key from insert with Oracle
>>
>>  I think this would be the preferred SQL for that:
>>
>>  select ids.currval from dual
>>
>>  ...where ids is your sequence's name.
>>
>>  Larry
>>  No virus found in this incoming message.
>>  Checked by AVG.
>>  Version: 8.0.100 / Virus Database: 269.23.10/1421 - Release Date:
> 5/7/2008
>>  5:23 PM
>>
>>
> No virus found in this incoming message.
> Checked by AVG.
> Version: 8.0.100 / Virus Database: 269.23.10/1421 - Release Date: 5/7/2008
> 5:23 PM
>
>
No virus found in this incoming message.
Checked by AVG. 
Version: 8.0.100 / Virus Database: 269.23.14/1425 - Release Date: 5/9/2008
12:38 PM


Mime
View raw message