Chip after Dave wrote...
>I have the same need that Dave outlined in his original post so
>I am interested in seeing any and all approaches to this problem.
> -lock the file with waiting
> -read the current "next number" from the file
> -increment the current "next number"
> -write the current "next number" back to the same record
> -unlock the file
Can't help with ODBC, but here is a JDBC snippet that I use...
private Connection con; // initialized somewhere else
...
con.setAutoCommit(false);
System.err.println("increment uniquekey");
Statement st = con.createStatement();
st.executeUpdate(
"update "
+ dbTableUniqueCount
+ " set dbsetcounter = dbsetcounter + 1;"
);
st.close();
System.err.println("retrieve uniquekey");
st = con.createStatement();
ResultSet rs = st.executeQuery(
"select dbsetcounter from "
+ dbTableUniqueCount
+ ";"
);
rs.next();
String uniqueKey = rs.getString("dbsetcounter");
rs.close();
st.close();
System.err.println("insert customer data (etc)");
// details snipped for brevity
System.err.println("insert patch list");
// details snipped for brevity
System.err.println("commit transaction");
con.commit();
con.setAutoCommit(true);
...
Sorry, if this is off-topic re ODBC. At least it is SQL (or close ;-)
Lars "corrections welcome"