Announcement Announcement Module
Collapse
No announcement yet.
bad SQL grammar / FROM keyword not found where expected Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • bad SQL grammar / FROM keyword not found where expected

    Code:
    	public List<DashboardBean> fin(){
    		@SuppressWarnings("unchecked")
    		List<DashboardBean> dashboardBeanList = jdbcTemplate
    					.query("select count(SLA_BREACHED) as SLA_EXCEED," +
    							"count(WITHIN_SLA) WITHIN_SLA,count(*) TOT_SR," +
    							"round((count(WITHIN_SLA)/count(*))*100,2) SLA_PER" +
    							"from " +
    							"(select CASE WHEN (DATE_COMMITED-CASE WHEN DATE_CLOSED is null " +
    							"THEN SYSDATE ELSE DATE_CLOSED END)>=0 " +
    							"THEN SR_NUMBER END 'SLA_BREACHED'," +
    							"CASE WHEN (DATE_COMMITED-CASE " +
    							"WHEN DATE_CLOSED is null " +
    							"THEN SYSDATE ELSE DATE_CLOSED END)<0 THEN SR_NUMBER END  'WITHIN_SLA'" +
    							"from sbl_service_request_v" +
    							"where SR_TYPE ='Complaint'" +
    							"and OWNING_DIVSION ='IT'" +
    							"and ASSIGNED_DIVISION  in ('CSO','IVR_IT')" +
    							"and to_char(ASSIGNED_DATETIME,'MM-YY') =to_char(sysdate,'MM-YY'))",
    											new Object[] {},
    								new RowMapper() {
    									  public DashboardBean mapRow(ResultSet rs, int rowNum)
    												  throws SQLException {
    										  DashboardBean dashboardBean = new DashboardBean();
    										  dashboardBean.setSlaExceed(Integer.valueOf(rs.getString("SLA_EXCEED")));
    										  dashboardBean.setWithinSla(Integer.valueOf(rs.getString("WITHIN_SLA")));
    										  dashboardBean.setTotSr(Integer.valueOf(rs.getString("TOT_SR")));
    										  dashboardBean.setSlaPer(Double.valueOf(rs.getString("SLA_PER")));
    										  return dashboardBean;
    									  }
    								});
    		return dashboardBeanList;
    	}
    ERROR COMES LIKE THIS

    Code:
    org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [select count(SLA_BREACHED) as SLA_EXCEED,count(WITHIN_SLA) WITHIN_SLA,count(*) TOT_SR,round((count(WITHIN_SLA)/count(*))*100,2) SLA_PERfrom (select CASE WHEN (DATE_COMMITED-CASE WHEN DATE_CLOSED  is null THEN SYSDATE ELSE DATE_CLOSED END)>=0 THEN SR_NUMBER END 'SLA_BREACHED', CASE WHEN (DATE_COMMITED-CASE WHEN DATE_CLOSED  is null THEN SYSDATE ELSE DATE_CLOSED END)<0 THEN SR_NUMBER END  'WITHIN_SLA'from sbl_service_request_vwhere SR_TYPE ='Complaint'and OWNING_DIVSION ='IT'and ASSIGNED_DIVISION  in ('CSO','IVR_IT')and to_char(ASSIGNED_DATETIME,'MM-YY') =to_char(sysdate,'MM-YY'))]; nested exception is java.sql.SQLSyntaxErrorException: ORA-00923: FROM keyword not found where expected|
    	at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate
    Code:
    java.sql.SQLSyntaxErrorException: ORA-00923: FROM keyword not found where expected|
    please help me friends...
    Last edited by priyanka_hdp; Apr 23rd, 2012, 02:02 PM. Reason: ...

  • #2
    Your query is flawed as therer is no space in front of the from leading to an invalid query string. This is the case on multiple lines btw. I suggest ending each line with a space.

    Comment

    Working...
    X