[thelist] TIP: Getting Autonumber Value in Access 97 and lowe r

Scott Dexter sgd at ti3.com
Tue Jun 20 00:25:17 2000


> 
> a. gaurenteed that the highest PK number is the last-entered?

good point; I was following the previous example of grabbing the max(); of
course you can grab the id field using a where clause of your choice

> b. gaurenteed that the two sql statements are executed 
> one-after-another
> 
> b is what worries me. I'm thinkng that it could be *possible* 
> for the first
> to be executed, then a SQL statement from another script, 
> then your max(id)
> statement.

I'm 98% positive this is so; as the queries are submitted as a batch, and
will execute serially. The 2% of me recalls a SQL optimization article I
read a couple years ago that talked about the SQL Server (6.5) query engine
sometimes reordering statements in a batch. It was in the context of
troubleshooting stored procedures....

and yeah, in a high volume scenario a race condition would exist, which I'd
point to (a) above to narrow your selection to make sure you grab the right
one...

an even more complete solution would be a stored procedure to do the update
and return the id. That way only one recordset is returned, and the
statements are compiled and ready to go. I can whip up an example if someone
wants (I know this started as an Access thread)

> 
> (just being me)

and we like you just the way you are =)


Rudy, any thoughts?

sgd
--
yeah yeah, whatever