Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    #31
    cheers!! I will definitely upgrade my SGWT to the latest version since I will be using this aggregation thingy a lot in my application.

    Comment


      #32
      I am testing this now on evaluation version of sgwt.My customer.ds.xml looks like this

      Code:
      <DataSource ID="CustomerDS" serverType="sql" tableName="Customer">
      	<fields>
      		<field name="id" title="Id" type="int" primaryKey="true" />
      		<field name="printName" title="Print Name" type="string" />		
      		<field name="neighbourhoodId" foreignKey="neighbourDS.id" />		
      	</fields>
      </DataSource>
      my neighbourDS.ds.xml looks like this

      Code:
      <DataSource ID="neighbourDS" serverType="sql" tableName="neighbourhood">
      	<fields>
      		<field name="id" type="integer" hidden="true" primaryKey="true"/>
      		<field name="neigbhour" nativeName="alternateName" title="neigbhour" type="text" />
      		<field name="zoneId" type="integer" customSQL="true" foreignKey="zoneDS.id"/>
      	</fields>
      </DataSource>
      and in this customerDS_1.ds.xml I am inheriting the customer.ds.xml and have used the includeFrom tag to call the different columns from many tables.
      Code:
      <DataSource ID="customerDS_1" serverType="sql" tableName="customer" inheritsFrom="CustomerDS">
      	<fields>
      		<field name="provincename" includeFrom="provinceDS.provincename" />
      		<field name="capital" includeFrom="provinceDS.capital" />
      		<field name="code" includeFrom="provinceDS.code" />
      		<field name="telcode" includeFrom="provinceDS.telcode" />
      		<field name="countyname" includeFrom="countyDS.countyname" />
      		<field name="district" includeFrom="districtDS.districtname" />
      		<field name="city" includeFrom="cityDS.cityname" />
      		<field name="taxcodecity" includeFrom="cityDS.taxcodecity" />
      		<field name="fdocode" includeFrom="cityDS.fdocode" />
      		<field name="zone" includeFrom="zoneDS.zone" />
      		<field name="neigbhour" includeFrom="neighbourDS.neigbhour" />
      		<field name="countCustomer" includeFrom="CustomerDS.printName" includeSummaryFunction="count"/>
      	</fields>
      </DataSource>
      what I am trying to do is to count the customers in each of the neigbhourhood and show it in the listgrid along with other cols. Now I am able to show all the cols except this customer count. I tried using this includeSummaryFunction but I get this error

      java.sql.SQLException: The objects "Customer" and "customer" in the FROM clause have the same exposed names. Use correlation names to distinguish them.

      my raw SQL query looks like this where I use the count clause to count the customer.just to give you an idea as to what I am trying to get from the SGWT inbuilt sql query

      Code:
      SELECT
          dbo.province.provincename as province,
          dbo.province.capital,
          dbo.province.code,
          dbo.province.telcode,
          dbo.county.countyname as county,
          dbo.district.districtname as district,
          dbo.city.cityname as city,
          dbo.city.taxcode,
          dbo.city.fdocode,
          dbo.zone.alternateName as zone,
          dbo.neighbourhood.alternateName as neigbhour,
          count(dbo.customer.printname) as countCustomer
      FROM
          dbo.county
      INNER JOIN
          dbo.province
      ON
          (
              dbo.county.provinceID = dbo.province.id)
      INNER JOIN
          dbo.district
      ON
          (
              dbo.county.id = dbo.district.countyID)
      INNER JOIN
          dbo.city
      ON
          (
              dbo.district.id = dbo.city.districtID)
      INNER JOIN
          dbo.zone
      ON
          (
              dbo.city.id = dbo.zone.cityId)
      INNER JOIN
          dbo.neighbourhood
      ON
          (
              dbo.zone.id = dbo.neighbourhood.zoneId)
      INNER JOIN
          dbo.customer
      ON
          (
              dbo.neighbourhood.id = dbo.customer.neighbourhoodId)
              Group By dbo.province.provincename,
          dbo.province.capital,
          dbo.province.code,
          dbo.province.telcode,
          dbo.province.taxcode,
          dbo.county.countyname,
          dbo.district.districtname,
          dbo.zone.alternateName,
          dbo.neighbourhood.alternateName,
          dbo.city.cityname,
          dbo.city.taxcode,
          dbo.city.fdocode
      Attached Files
      Last edited by zaj; 17 Dec 2014, 00:45.

      Comment


        #33
        This might refer to relatedTableAlias as both your DS have a tableName="Customer" attribute.

        The error you are getting is to let you know that the SQL that could be generated from your data will fail because of the tablenames used.

        Best regards,
        Blama

        Comment


          #34
          Hi Blama,

          Thanks for your feedback.

          Happy holidays,

          Zolf

          Comment

          Working...
          X