×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Text
Posted by: sumesh tg
Added: Dec 14, 2016 6:26 AM
Views: 7
Tags: check exists
  1.         jdbcTemplate = new JdbcTemplate(dataSource);
  2.         String sql = null;
  3.         if (curRowId == null) {
  4.             sql = "SELECT count(*) FROM " + TableNames.TBL_INV_MSTR_COUPON_CODE + "\n"
  5.                     + "WHERE coupon_code=? OR coupon_name=?";
  6.         } else {
  7.             sql = "SELECT count(*) FROM " + TableNames.TBL_INV_MSTR_COUPON_CODE + "\n"
  8.                     + "WHERE (coupon_code=? OR coupon_name=?) AND coupon_id<>'" + curRowId + "'";
  9.         }
  10.         int row = jdbcTemplate.queryForObject(sql, new Object[]{couponCodeBEAN.getCouponCode(), couponCodeBEAN.getCouponName()}, Integer.class);
  11.         return (row > 0);