Каким из?
Код:
public void updateFlagParam(int cid, int pid, boolean value, int userId)
{
int changeRows = 0;
ResultSet rs = null;
PreparedStatement ps = null;
try
{
int index = 1;
int foundRows = 0;
ps = this.con.prepareStatement("SELECT count(*) FROM contract_parameter_type_5 WHERE cid=? AND pid=?");
ps.setInt(index++, cid);
ps.setInt(index++, pid);
rs = ps.executeQuery();
while (rs.next()) {
foundRows = rs.getInt(1);
}
rs.close();
ps.close();
index = 1;
if (foundRows == 0)
{
ps = this.con.prepareStatement("INSERT INTO contract_parameter_type_5 SET cid=?, pid=?, val=?");
ps.setInt(index++, cid);
ps.setInt(index++, pid);
ps.setBoolean(index++, value);
changeRows = ps.executeUpdate();
ps.close();
}
else
{
ps = this.con.prepareStatement("UPDATE contract_parameter_type_5 SET val=? WHERE cid=? AND pid=? AND NOT(val<=>?)");
ps.setBoolean(index++, value);
ps.setInt(index++, cid);
ps.setInt(index++, pid);
ps.setBoolean(index++, value);
changeRows = ps.executeUpdate();
ps.close();
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
if ((changeRows > 0) && (checkParameterHistoryLogging(pid))) {
updateFlagParamLog(cid, pid, Boolean.valueOf(value), userId);
}
}