JAVA查询某个字段为空,返回个true或false,然后更新这个字段,怎么简化下,能不能放到一个SQL语句里string str=null;
String sql = ("select salesmanname from order where orderID = '"+033+"'");
sta.executeQuery(sql)
try {
while(rs.next()) {
str = rs.getString(1);
}
if(str != null) {
isname = true; //如果为空 返回true,反之返回false
return;
}
else {
isname = false
Strin sql = ("update order set salesmanname ='"+NewName+"' where orderID = '"+033+"'");
sta.executeQuery(sql);
}
} catch (Exception e) {
e.printStackTrace();