我正在尝试在 smartgwt 中使用 SQL 模板将数据从我的数据库加载到 listgrid 中,但我无法获得所需的结果。这是我试图在 SmartGWT 中采用的原始 SQL 查询以获得结果
SELECT
dbo.province.provincename as province,
dbo.province.capital,
dbo.province.code,
dbo.province.telcode,
dbo.province.taxcode,
dbo.county.countyname as county,
dbo.district.districtname as district,
dbo.zone.alternateName as zone,
dbo.neighbourhood.alternateName as neigbhour,
dbo.city.cityname as city,
dbo.city.taxcode,
dbo.city.fdocode,
count(dbo.customer.customeraltname) 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
下面是我的 ds.xml
<DataSource ID="CusNeiGroupDS" serverType="sql">
<fields>
<field name="id" type="integer" />
<field name="provincename" title="province" type="text"/>
<field name="capital" title="capital" type="text"/>
<field name="code" title="code" type="text"/>
<field name="telcode" title="telcode" type="text"/>
<field name="taxcode" title="taxcode" type="text" />
<field name="provinceId" type="integer" tableName="county"/>
<field name="countyname" title="county" type="text" tableName="county"/>
<field name="district" title="district" type="text" />
<field name="city" title="city" type="text" />
<field name="zone" title="zone" type="text" />
<field name="neighbour" title="neighbour" type="text" />
<field name="taxcodecity" title="taxcodecity" type="text"
/>
<field name="fdocode" title="fdocode" type="text" />
<!-- <field name="countCustomer" title="countCustomer" type="int" /> -->
</fields>
<operationBindings>
<operationBinding operationId="summary"
operationType="fetch">
<selectClause>
districtname as
district,
alternateName as zone,
alternateName as neigbhour,
cityname
as city,
fdocode
</selectClause>
<tableClause>province, county, district, zone, neighbourhood, city
</tableClause>
<whereClause>
province.Id = county.provinceId
AND district.countyId = county.Id
AND city.districtId = district.Id
AND neighbourhood.zoneId = zone.Id
</whereClause>
</operationBinding>
</operationBindings>
我得到的错误是
执行选择:SELECT COUNT(*) FROM CusNeiGroupDS WHERE ('1'='1') on db:SQLServer 抛出异常:java.sql.SQLException:无效的对象名称 'CusNeiGroupDS'。- 假设连接过时并重试查询。
但是当我像这样将表名放在数据源中时,我会得到输出,但只能从我提到的那个表中得到输出,而不是从与 FK 连接的其他表中得到输出。
<DataSource ID="CusNeiGroupDS" serverType="sql" tableName="province">