| Author |
preapareStatement with condition
|
sahidul karim
Greenhorn
Joined: Sep 19, 2006
Posts: 28
|
|
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
Joined: Sep 06, 2003
Posts: 259
|
|
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 ?
|
http://www.skillassert.com
|
 |
sahidul karim
Greenhorn
Joined: Sep 19, 2006
Posts: 28
|
|
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
Joined: Sep 06, 2003
Posts: 259
|
|
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.
|
 |
 |
|
|
subject: preapareStatement with condition
|
|
|