Change that first line to use a PreparedStatement, rather than a Statement, so it becomes:
PreparedStatement ps = conn.prepareStatement("select * from prototypes where prototype_id=?"); ps.setInt(1, Candidate_ID); rs = ps.executeQuery(); On Wed, Dec 12, 2018 at 7:18 PM Bob M <rgmatth...@orcon.net.nz> wrote: > > I have a table with a first column as ID (integer) and this column is the > primary key > > I do some calculations to decide which record I wish to retrieve > and end up with the following integer value variable called Candidate_ID > > The table also has a column called Occurances (integer) which I wish to > update by adding 1 > *************************************************************** > rs = s.executeQuery("SELECT * FROM PROTOTYPES WHERE Prototype_ID = > Candidate_ID"); > rs.next(); > s.setCursorName("MYCURSOR"); > rs = s.executeQuery("SELECT Occurances FROM PROTOTYPES WHERE Prototype_ID = > Candidate_ID_to_be_validated FOR UPDATE"); > rs.next(); > psUpdate = conn.prepareStatement("UPDATE PROTOTYPES SET Occurances = ? WHERE > CURRENT OF MYCURSOR"); > statements.add(psUpdate); > psUpdate.setInt(1, Occurances + 1); > psUpdate.executeUpdate(); > **************************************************************** > I am getting an error on the first line of code > SQL State: 42X04 > Error Code: 20000 > Message: Column 'Candidate_ID' is either not in any table or................ > > What should I change in the first line ? > > Bob M > > > > > -- > Sent from: > http://apache-database.10148.n7.nabble.com/Apache-Derby-Users-f95095.html