Quantcast
Channel: SQL Server Spatial forum
Viewing all articles
Browse latest Browse all 364

Calling UDF From Cursor

$
0
0

I have a table in which there is a xml data type column for storing xml data. I want to call my function foreach xml data record from a SQL query and when result returned then check intersection of two polygons by STIntersections method. The function accept xml data as input parameter and returns geography data in the format 

POLYGON((66.9214310204
30.1191654521,66.9724466643 30.1273507980,66.9612156084 30.1614246796,66.9324717194 30.1540007613,66.9214310204 30.1191654521))

Below is the code that I have tried but not giving me the results

Declare@aoi geographyDeclare@xmlxmlDeclare@result geographySET@aoi=geography::STGeomFromText('POLYGON((66.9214310204
30.1191654521,66.9724466643 30.1273507980,66.9612156084 30.1614246796,66.9324717194 30.1540007613,66.9214310204 30.1191654521))',4326);--creating cursor to hold results for function calling Declare xmlDataCursor CURSORforselect XmlFiles.xmlData from XmlFilesOPEN xmlDataCursorFETCH NEXT FROM xmlDataCursor INTO@xmlWHILE@@FETCH_STATUS=0BEGINSelect@xmlWhere(@aoi.STIntersects(dbo.MakePolygon(@xml))=1)FETCH NEXT FROM xmlDataCursor INTO@xmlENDCLOSE xmlDataCursorDEALLOCATE xmlDataCursor'


Engr. Mudassar Ali Software Engineer


Viewing all articles
Browse latest Browse all 364

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>