db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bob M <rgmatth...@orcon.net.nz>
Subject selecting a particular record from a derby table
Date Thu, 13 Dec 2018 03:12:16 GMT
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

Mime
View raw message