When you insert a record with an IDENTITY columns (aka auto incrementing PK), you may return the column number in the resultset by using @@IDENTITY ie.
 
INSERT User( Name, Age) VALUES( 'John Doe', 21)
 
SELECT nUserID = @@IDENTITY
 
-----Original Message-----
From: Jay Walters [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 03, 2000 6:48 AM
To: 'jBoss'
Subject: RE: [jBoss-User] SQLServer getting autoincrement pk

should be able to do it with a stored procedure, I'm not sure of the specific syntax to access the last key generated -
-----Original Message-----
From: Bill Pfeiffer [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 03, 2000 5:56 AM
To: jBoss-user
Subject: [jBoss-User] SQLServer getting autoincrement pk

Does anyone know of a strategy for retrieving an  auto-generated pk from sql server autoincrement pk when using entity beans?  Ideally I would like the pk returned from the create to contain the newly generated pk.
 
Any ideas?
 
TIA,
 
Bill Pfeiffer

Reply via email to