This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

preapareStatement with condition

 
sahidul karim
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can i give any condition in prepareStatement?
I wrote like this way
insert into leave(EMP_ID,LEAVE_TYPE,ELIGIBLE,AVAILED) values (?,?,?,?)where ELIGIBLE<15 AND AVAILED<15 .

update sm_leave_details set eligible = ? , availed = ? where emp_id = 111 and leave_type = ? AND where ELIGIBLE<15 AND AVAILED<15"
These are not working.what will be the correct syntax for validating eligible and availed less than 15?
 
karthikeyan Chockalingam
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the error you are getting ? what is the data type of eligible and availed?
The table name differs (its sm_leave_details in update and leave in create )..Is it okay ?
 
sahidul karim
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya that is ok. I am inserting and updating in two different table.
the data type of eligible and availed is int
the error is showing:-java.sql.SQLException: Syntax error or access violation, message from server: "
You have an error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near 'where ELIGIBLE<15 AND AVA
ILED<15' at line 1"
 
karthikeyan Chockalingam
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot have where ELIGIBLE<15 AND AVAILED<15 in the insert statement.

Just have insert into leave(EMP_ID,LEAVE_TYPE,ELIGIBLE,AVAILED) values (?,?,?,?) as the query.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic