I'm trying to output a stored procedure from Sql Server into an output of a coldfusion page. The coldfusion page calls the stored procedure correctly, but only part of the data is returned (xml is truncated). When I call the stored procedure within sql server, it gives the entire XML document with no fails. I'm wondering if Coldfusion has a limit, or am I not working the code correctly.
Here's the stored procedure:
USE [myschema]
GO
/****** Object: StoredProcedure [dbo].[GEOIDKMLZIP] Script Date: 9/18/2015 10:28:40 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[GEOIDKMLZIP] @Zip int
AS
DECLARE @kml XML
DECLARE @kmlout NVARCHAR(MAX)
SELECT @kml = CAST(concat('<?xml version="1.0" encoding="utf-16" ?>',
'<kml xmlns="http://www.opengis.net/kml/2.2">',
'<Document>',
' <Style id="Licensed">
<LineStyle>
<color>ff000000</color>
<width>2</width>
</LineStyle>
<PolyStyle>
<color>1e1400FF</color>
<fill>1</fill>
<outline>1</outline>
</PolyStyle>
</Style>
<Style id="NotLicensed">
<LineStyle>
<color>ff000000</color>
<width>2</width>
</LineStyle>
<PolyStyle>
<color>1e14F0FF</color>
<fill>1</fill>
<outline>1</outline>
</PolyStyle>
</Style>
<Style id="Other">
<LineStyle>
<color>ff000000</color>
<width>2</width>
</LineStyle>
<PolyStyle>
<color>1e007800</color>
<fill>1</fill>
<outline>1</outline>
</PolyStyle>
</Style>' ,
(
select
'<![CDATA[{"Zip":"' + z.ZipCode + '", "GEOID": "'+ z.GEOID+'"}]]>' as name,
case t.IsLicensed
when 2 then '#Licensed'
when 1 then '#NotLicensed'
else '#Other'
end as styleUrl,
polygons as Geometry
from ZipCodeGEOID z
join Tracts t on t.GEOID = z.GEOID
join census_county_ref c on t.GEOID = c.GEOID
where z.ZipCode = @Zip
FOR XML PATH('Placemark'), ELEMENTS), '</Document></kml>') AS XML)
--
-- Perform replacement of < and > with < and > respectively
--
SET @kmlout = REPLACE(REPLACE(REPLACE(REPLACE(CAST(@kml AS NVARCHAR(MAX)), '<', '<'), '>', '>'), '<Geometry>', ''), '</Geometry>', '')
SET @kmlout = REPLACE(@kmlout, 'utf-16', 'utf-8')
--
-- Return kmlout
--
SELECT @kmlout as kml
and here's zip2tractkml.cfm
<cfsetting showdebugoutput="yes">
<cfheader name="Content-Type" value="application/xml">
<cfstoredproc procedure="GEOIDKMLZIP" datasource="buyerhero">
<cfprocparam value="#URL.ZIP#" cfsqltype="CF_SQL_INTEGER">
<!--- One resultset is returned called "qEmployees" --->
<cfprocresult name="response" resultset="1">
</cfstoredproc>
<cfset kml = XmlParse(response.kml)>
<cfoutput>#kml#</cfoutput>
I also tried just outputing the result with out the cfset:
<cfsetting showdebugoutput="yes">
<cfheader name="Content-Type" value="application/xml">
<cfstoredproc procedure="GEOIDKMLZIP" datasource="buyerhero">
<cfprocparam value="#URL.ZIP#" cfsqltype="CF_SQL_INTEGER">
<!--- One resultset is returned called "qEmployees" --->
<cfprocresult name="kml" resultset="1">
</cfstoredproc>
<cfoutput>#kml.kmlout#</cfoutput>
but I got the same response (truncated xml). again, when I run this in SQL Server using:
EXEC [dbo].[GEOIDKMLZIP]
@Zip = N'53554'
GO
It works like a charm, and the XML is formatted properly. What am I missing? Thanks