• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

SQLException: bind variable does not exist

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic