To use multithreading safely, you must use a different connection for each thread. When you do this, CALL IDENTITY() will return the correct value for the session no matter when it is called.
 
Fred
----- Original Message -----
To: 'fredt'
Sent: 02 June 2004 23:59
Subject: RE: [Hsqldb-developers] Possible Issue with call Identity() with prepared statement in 1.7.2

Ok, then is there an atomic way to do an insertion and get the identity back reliably?   We are a very multi-threaded app and while I realize the hsqldb engine single threads it but we're trying to avoid   thread1 insert, thread 2 insert, thread 1 identity (comes away with thread 2's identity)
 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of fredt
Sent: Wednesday, June 02, 2004 3:47 PM
To: [EMAIL PROTECTED]
Subject: Re: [Hsqldb-developers] Possible Issue with call Identity() with prepared statement in 1.7.2

1.7.2 simply implements the standards more rigorously. You cannot have two SQL statements in one prepareStatement() calls.
 
Fred
----- Original Message -----
Sent: 02 June 2004 21:40
Subject: [Hsqldb-developers] Possible Issue with call Identity() with prepared statement in 1.7.2

We are getting an unexpected issue that seems to be a change between 1.7.1 and 1.7.2 - we had code working quite well and shipping for 1.7.1 that is now broken
 
Prepared statement:
insert into tablefoo ( id, name, value ) values ( ?, ?, ?); call identity();
 
This statement used to work but does not anymore (blows up with current 1.7.2 rc6b (and previous)
 
sample schema definition:
 
create table tablefoo (
    id integer IDENTITY,
    name varchar not null,
    value varchar null
    )
 
 
Error message generated:
java.sql.sqlexception: Unexpected token: CALL in statement [insert into tablefoo ( id, name, value ) values ( ?, ?, ?); call identity();]
 
 
 

Andrew Chandler

Manager DataCollection Group      Phone : 650-470-8920x1535

Visionael Corporation             Fax   : 650-470-8921

410 Cambridge Ave                 Email : [EMAIL PROTECTED]

Palo Alto, CA. 94306              WEB   : www.visionael.com

 

Reply via email to