Results 1 to 2 of 2

Thread: bad SQL grammar / FROM keyword not found where expected

  1. #1
    Join Date
    Sep 2010
    Location
    Sri Lanka
    Posts
    61

    Question 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 at 02:02 PM. Reason: ...

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,629

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •