I have a table which I am updating using a JDBC call, however my question should be independent of how I make the query. I wish to add a row "if the value of a is not already in column x of table tbl."
Above is the code I need to edit--after "VALUES(?,?,?)" I need to add the conditional clause, but I'm not sure how to do it exactly. I was going to test and IF() statement and use that to determine whether or not to add the row, unfortunately I don't know what test to use ( IF(input_parameter NOT IN tbl) == TRUE ).
PH
I hope the formatting is not destroyed.
code:<HR>Code:String addRows = "INSERT INTO " + DEVICE_TABLE + " ( ip, mac, host) " + "VALUES ( ?, ?, ?)"; PreparedStatement addTableRow = dbConn.prepareStatement(addRows); addTableRow.setString(1, _ip); addTableRow.setString(2, _mac); addTableRow.setString(3, _host); int rowsUpdated = addTableRow.executeUpdate(); // Execute update.
Above is the code I need to edit--after "VALUES(?,?,?)" I need to add the conditional clause, but I'm not sure how to do it exactly. I was going to test and IF() statement and use that to determine whether or not to add the row, unfortunately I don't know what test to use ( IF(input_parameter NOT IN tbl) == TRUE ).
PH
I hope the formatting is not destroyed.