我在sqlserverdb中有一个表,其中包含列名EntityType,EntityJson.In EntityJson列包含以下json值,
{"EntityId":{"Type":"String","Value":"bf58bbc6-0a5a-b9e0-4fb6-5e55604a1b68"},"Name":{"Type":"string","Value":"GasAssets"},"TenantName":{"Type":"string","Value":"v2rdemo"},"TenantId":{"Type":"string","Value":"c091e548-b45a-49b4-b8ec-2cb5e27c7af6"},"EntityType":{"Type":"string","Value":"EntityAssets"},"CreatedBy":{"Type":"string","Value":""},"ModifiedBy":{"Type":"string","Value":""},"Created":{"Type":"string","Value":""},"Modified":{"Type":"string","Value":""},"Parent":{"Type":"string","Value":""},"LastChat":{"Type":"string","Value":""},"Latitude":{"Type":"string","Value":-33.3479019999504},"Longitude":{"Type":"string","Value":6.203906305532271}}
和EntityType列值为“EntityAssets”。
在GeoServer上,我编写了以下查询
SELECT
geometry::STGeomFromText('POINT(' + CAST(JSON_VALUE(EntityJson, '$.Latitude.Value') As CHAR(20)) + ' ' + CAST(JSON_VALUE(EntityJson, '$.Longitude.Value') AS CHAR(20)) + ')', 4326) as geometria
FROM
dbo.Entities
where
EntityType = 'EntityAssets'
在点击openlayer上预览图层时,我遇到了同样的异常。
但是在Microsoft Sql Server Mgmt Studio中运行它正常使用where子句并且如果我删除where子句并再次执行Query而没有where子句在Sql Server Mgmt studio上获得相同的异常。
预计输入的第47位会有一个数字。输入有)。
答案 0 :(得分:0)
如果没有看到您的数据,很难确定,但错误听起来就像您有一行没有或空Latitude.Value
和Longitude.Value
。运行此查询将导致非常类似的错误:
SELECT
geometry::STGeomFromText('POINT(' + '' + ' ' + '' + ')', 4326) as geometria
FROM
dbo.Entities
这会模拟你的两个CAST返回空字符串。