I have a method which returns record from a database based on a id's. Now I need to fetch records for 1000 records and I feel like it is not a good practice to write all id's in the in clause manually. Is there a tool where I paste the id's and it gives me like this id in ('123', '456', and so on)?
I can't write all the id's by my self manually.Business provides the id's in excel and they are very large in number. is there a way to accomplish this?
My method
@Override
public List<NYProgramTO> getLatestNYData() throws Exception {
String query = "SELECT REQ_XMl, SESSIONID, EXPIRATION_DATE, QUOTE_DATE, POLICY_EFFECTIVE_DATE, TARGET_CREATED, RATING_TRANSACTION_ID, SOURCE_LASTMODIFIED FROM dbo.XML_SESSIONS with (nolock) WHERE XML_SESSIONS.LOB = 'PersonalAuto' AND XML_SESSIONS.RATING_STATE = 'NY' AND XML_SESSIONS.ID IN ('72742212', '71289432') ORDER BY XML_SESSIONS.SOURCE_LASTMODIFIED DESC";
return this.sourceJdbcTemplate.query(query, (rs, rowNum) -> {
NYProgramTO to = new NYProgramTO();
to.setRequestXML(rs.getString("REQ_XML"));
to.setSessionId(rs.getString("SESSIONID"));
to.setExpirationDate(rs.getDate("EXPIRATION_DATE"));
to.setQuoteDate(rs.getString("QUOTE_DATE"));
to.setEffectiveDate(rs.getDate("POLICY_EFFECTIVE_DATE"));
to.setCreatedDate(rs.getDate("TARGET_CREATED"));
to.setRatingTransactionID(rs.getString("RATING_TRANSACTION_ID"));
to.setSourceLastModified(rs.getTimestamp("SOURCE_LASTMODIFIED"));
return to;
});
}
Thanks