Re: Find Autonum just Entered

2001-04-04 Thread Ian Summers

I use

 SELECT MAX(OrderID) FROM tblOrder

which should work ok if no one else has updated the table

Ian

At 22:02 03/04/2001 +0100, you wrote:
On Tue, Apr 03, 2001 at 12:08:03PM +0100, Roland Corbet wrote:
  I'm Using DBI::ODBC with MS Access 200.
 
  Can anyone tell me what is the best way of getting hold of the Autonumber
  that has just been entered into the database with the previously executed
  SQL statement.
 
  Perhaps a "select Max from Tablename"?  The site is only going to have
  low-usage, so I would think this might be acceptable, as it's very 
 unlikely
  that someone could have entered another entry between the insert and 
 select
  max statements.
 
  I was just wondering if there was a 'watertight' method that I could adopt
  instead of "select max"?

You may find that

 select * from tablename where Autonumber_column IS NULL

magically does the right thing (a vague memory that may be wrong).

Tim.




Find Autonum just Entered

2001-04-03 Thread Roland Corbet

I'm Using DBI::ODBC with MS Access 200.

Can anyone tell me what is the best way of getting hold of the Autonumber 
that has just been entered into the database with the previously executed 
SQL statement.

Perhaps a "select Max from Tablename"?  The site is only going to have 
low-usage, so I would think this might be acceptable, as it's very unlikely 
that someone could have entered another entry between the insert and select 
max statements.

I was just wondering if there was a 'watertight' method that I could adopt 
instead of "select max"?

TIA for you time and help.

Cheers,

Roland




Re: Find Autonum just Entered

2001-04-03 Thread Tim Bunce

On Tue, Apr 03, 2001 at 12:08:03PM +0100, Roland Corbet wrote:
 I'm Using DBI::ODBC with MS Access 200.
 
 Can anyone tell me what is the best way of getting hold of the Autonumber 
 that has just been entered into the database with the previously executed 
 SQL statement.
 
 Perhaps a "select Max from Tablename"?  The site is only going to have 
 low-usage, so I would think this might be acceptable, as it's very unlikely 
 that someone could have entered another entry between the insert and select 
 max statements.
 
 I was just wondering if there was a 'watertight' method that I could adopt 
 instead of "select max"?

You may find that

select * from tablename where Autonumber_column IS NULL

magically does the right thing (a vague memory that may be wrong).

Tim.