Hello - I am having problems setting values for my prepared statement (below).
psViewLogIncrement = conn.prepareStatement( SELECT TOP ? * FROM Log WHERE (record_id >=(SELECT MAX(record_id)FROM (SELECT TOP ? * FROM Log ORDER BY record_id) nextRecords)) ORDER BY record_id ); psViewLogIncrement.setInt(1, 2); psViewLogIncrement.setInt(2, 2);
The values I would like to set are not data field values, but the number of values I would like the Select to return. The error I'm getting is: "java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Invalid parameter binding(s)."
Hi Gale, Unfortunately, you cannot put a place holder (i.e. question-mark ["?"]) anywhere you want to, in a "PreparedStatement" -- and that is what you are trying to do -- hence the "Invalid parameter bindings" error message you are receiving. You could do something like this: [Note: Only a suggestion]
Good Luck, Avi.
Joined: Aug 05, 2002
Ahh ha! I actually did what you had suggested and used a "Statement" instead of a "PreparedStatement". Thanks so much for your reply - much appriciated!