insert a row with next available id

  • Thread starter Thread starter ivan.svaljek
  • Start date Start date
I

ivan.svaljek

INSERT INTO table (idn,idkup) VALUES (SELECT MAX(idn)+1 FROM table, ?)

does not work.

nor does:

INSERT INTO table (idn,idkup) SELECT (SELECT MAX(idn)+1 FROM table, ?)
as idn, ? as idkup
 
Use an autonumber column is the best solution
If you cant, do a DLOOKUP to get the max key so far, then a serparate INSERT
command. But this is error-prone because an intervening insert could be done
between the 2 statements executing.

-Dorian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top