Thank you Dyre for a brilliant reply.................. I do have a TRADE_ID number Also, I only ever have ONE open trade at any point in time I follow your three points completely
Because I already have code which retrieves x records ordered by date and time I am considering the following code to answer my own question ************************************************* // retrieve and update date and time of penultimate record // I retrieve the latest 2 records rs = s.executeQuery("SELECT * FROM TABLE ORDER BY Date ASC," + " Time ASC OFFSET x ROWS FETCH NEXT 2 ROWS ONLY"); myConsole.getOut().println("Successfully retrieved latest 2 records from TABLE: "); rs.next(); String Date3 = rs.getString("Date"); int Time3 = rs.getInt("Time"); s.setCursorName("MYCURSOR"); rs = s.executeQuery("SELECT * from TABLE WHERE Date = '" + Date3 + "' AND Time = " + Time3 + " FOR UPDATE"); rs.next(); conn.prepareStatement("UPDATE FROM TABLE SET PROFIT_LOSS = profit WHERE CURRENT OF MYCURSOR").executeUpdate(); myConsole.getOut().println("Updated penultimate record"); ******************************************* Bob M -- View this message in context: http://apache-database.10148.n7.nabble.com/Inserting-and-deleting-records-tp143723p143729.html Sent from the Apache Derby Users mailing list archive at Nabble.com.