in reply to ActivePerl sql connection~PLEASE HELP!!

You have a race condition in there...what if someone inserts into the ECAST_LOT table after you've selected the latest id, but before you've inserted into it? Look at DBIx-Sequence for a correct way of doing this sort of thing, or use built in sequences, auto-increment or unique-id columns, or whatever your database supports.

And SELECT TOP 1 IDX FROM ECAST_LOT ORDER BY IDX DESC seems like an inefficient way of doing SELECT max(IDX) FROM ECAST_LOT (how big is the table on each server? is there an index on the column or is it a primary key?). Also, I hope none of the fields being inserted has single quotes in it.

.