• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

preapareStatement with condition

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic