• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQLException: bind variable does not exist

 
Karthika Kannan
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to insert a row into a table(Oracle) from a java program, using a sequence(seq.nextval) as the primary key.I'm using a prepared statement for this query:
INSERT INTO TEST VALUES(ERROR_SEQ.nextval,?,?)

I'm getting the following exception:

ORA-01006: bind variable does not exist

Stack Tracejava.sql.SQLException: ORA-01006: bind variable does not exist

Could somebody help me out.
Thanks.

Karthika
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like you are trying to mind a variable that does not exist in your statement. Check your code - are you tring to bind more than two variables?
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Karthika,

Could you post your code so that we can find exact problem.Untill then we can guess only.

A common mistake by developers is that whenever they use sequences etc they increment the sqequence number of place holder, possibily same error is here are u doing similar like code below

pstmt(2,Your_First_place_holder);
pstmt(3,Your_Second_place_holder);


Shailesh
 
Ann Klein
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SQLquery =
" DECLARE x report_help.seqid%TYPE; " +
" BEGIN " +
" INSERT INTO report_help " +
" ( helptext, creationdate, modifydate ) " +
" VALUES ( ? ,SYSDATE, SYSDATE) " +
" RETURNING x " +
" INTO x; " +
" RETURN; " +
" END;";

int x = 0;
CallableStatement cstmt = null;
try
{
WebLogger.println("SQLquery: " + SQLquery );
cstmt = dbConn.prepareCall(SQLquery);
cstmt.setString(1, v_helptext );
cstmt.registerOutParameter(2, java.sql.Types.TINYINT);
cstmt.executeQuery();
WebLogger.println("x: " + x );
if (rs.next()) {
x = rs.getInt(2);
WebLogger.println("from rs x: " + x );
}
cstmt.close();

getting error on cstmt.executeQuery();
Message: ORA-01006: bind variable does not exist
SQLState: 72000
ErrorCode: 1006
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic