[thelist] DB increments without an auto increment

Steve Cook steve.cook at evitbe.com
Mon Apr 8 10:43:01 CDT 2002


Hi folks!

I have a problem with a legacy database I am writing a new application for.
The database has an ID field, but no autoincrement, instead new ID's are
generated programmatically. Normally this is no major problem (SELECT
MAX(ID)+1 will do the trick), but I now find myself needing to update the
table with info from another table. (Nope, I can't update the field, it
breaks the very old Delphi application that also uses the data).

I can step though the data programmatically and do a series of inserts if
needs be, but what I *want* to do is something like the following:

INSERT INTO Logg (ID, cardNum, persName)
	SELECT (SELECT MAX(ID) FROM Logg)+1, relMailTemp.cardNum,
relMailTemp.Name
	FROM relMailTemp

The problem is that if I have multiple entries in relMailTemp then they all
get assigned the same ID number. Is there any way to make the ID number
continue incrementing for each row of data it pulls from relMailTemp?

Cheers for any tips.

.steve

----------------------------------
 Cookstour - http://cookstour.org
----------------------------------



More information about the thelist mailing list