#Result macro

From: dan17..elus.net
Date: Thu Jun 17 2004 - 12:16:27 EDT

  • Next message: McDaniel, Joe R.: "RE: How to create JOIN query"

    I'm using SQLTemplate to generate aggregated values.

    This is my sql statement:

    String sql = "select " +
    "#result('eez.entity_id' 'Integer')," +
    "#result('p.yearmonth' 'Integer'), " +
    "#result('sum(p.value)' 'BigDecimal' 'total')" +
    " from economic_entity_zone eez, production p" +
    " where (eez.zone_id = p.zone_id) and (eez.entity_id = #bind($helper.cayenneExp
    ($entity, 'db:ENTITY_ID')))" +
    " group by eez.entity_id, p.yearmonth";

    When this is sent to oracle. I get:

    select eez.entity_id, p.yearmonth, sum(p.value) AS total
    from economic_entity_zone eez, production p
    where (eez.zone_id = p.zone_id) and (eez.entity_id = 1234)
    group by eez.entity_id, p.yearmonth

    In Oracle SQL, you don't use the keyword "AS" when aliasing a column. The SQL
    should read:

    select eez.entity_id, p.yearmonth, sum(p.value) total from [...]

    How do I suppress the "AS"?

    - Dan



    This archive was generated by hypermail 2.0.0 : Thu Jun 17 2004 - 12:16:29 EDT