Yes, but like I said, by default (i think but check it out) SQL Server
creates an implicit transaction for each statement. So if you poll
the @@IDENTITY value immediately after your INSERT you should have the
id for that insert. If you want to be sure to be sure you can place
both the INSERT and the @@IDENTITY check inside an explicit BEGIN TRAN
END TRAN.
-Ferghil
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Travis Reeder
Sent: Friday, June 09, 2000 11:15 AM
To: [EMAIL PROTECTED]
Subject: Re: Getting just added ID column
Ya, I know that you can use that to get the newest id column, but what
happens if 2 inserts happen at the same time and you grab the wrong id?
Travis
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Ferghil O'Rourke
Sent: Thursday, June 08, 2000 5:24 PM
To: [EMAIL PROTECTED]
Subject: Re: Getting just added ID column
On MS SQLServer anyway the global variable @@IDENTITY will
always give the last id inserted. I'm pretty sure that's for
the current transaction.
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Travis Reeder
Sent: Thursday, June 08, 2000 5:21 PM
To: [EMAIL PROTECTED]
Subject: Getting just added ID column
What's the best way to get the id from the identity column after you just
made an insert and ensuring that you get the correct one? I don't want to
know about the SQL syntax, but rather, is there a way to lock the database
to make sure you get the right one? Or is there some better way that
doesn't require locking?
Travis Reeder
Director, Internet Technologies
Xabre.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets