Hi there,
I have the following preparedStatement:
The issue I am facing that sometimes I want to run the delete and some sometimes don't want so. AND I want to run the delete and insert in the batch in sequence.
the following includes my code where productProperties includes the list of each product and its properties
on the first iterate I want to delete so I fill in variables and else I don't want to so I fill in NULL
HOW can I get rid of executing the delete query when it NULL since it does not do nothing?
I have the following preparedStatement:
Code:
PreparedStatement proPreStProdProperties= connection.prepareStatement(" " +
" DELETE FROM properties" +
" WHERE id_itm = ?" +
" " +
" INSERT INTO properties " +
" (id_itm,property_key,property_value) "+
" VALUES (?,?,?) ");
The issue I am facing that sometimes I want to run the delete and some sometimes don't want so. AND I want to run the delete and insert in the batch in sequence.
the following includes my code where productProperties includes the list of each product and its properties
on the first iterate I want to delete so I fill in variables and else I don't want to so I fill in NULL
Code:
for (int i = 0 ; i< productProperties.length;i++){
if(productProperties[i].getTrnsTypeCode().equals(ATransaction.A)){
if(i == 0){
proPreStProdProperties.setString(1, item);
}else{
proPreStProdProperties.setNull(1, Types.VARCHAR);
}
proPreStProdProperties.setString(2,item);
proPreStProdProperties.setString(3,productProperties[i].getPropertyKey());
proPreStProdProperties.setString(4,productProperties[i].getPropertyValue());
proPreStProdProperties.addBatch();
}
HOW can I get rid of executing the delete query when it NULL since it does not do nothing?