[Mapserver-users] OGR Layer with SQL

Frank Warmerdam warmerdam at pobox.com
Wed Jul 28 16:23:21 EDT 2004


Blaine Hackett wrote:
> All
> 
> I made a mistake on my last email.  Actually disregard
> that one and read this one instead. 
> 
> I am having a problem using SQL with OGR.
> 
> This SQL statement will work(ID is a number field):
> <SrcSQL>SELECT * FROM subset WHERE (ID > 35) </SrcSQL>
> This one will NOT:
> <SrcSQL>SELECT * FROM subset WHERE (ID > 0) AND (ID <
> 35)</SrcSQL> 
> I get the following error: 
> "msOGRFileOpen(): OGR error. Open failed for OGR
> connection ` ODBC:ODBC:user/pass at minnesotadata SELECT
> * FROM subset WHERE (ID > 0) AND (ID < 50) wkbPoint
> WGS84 '. File not found or unsupported format. "
> 
> When I try to use it with a date field such as this:
> <SrcSQL>SELECT * FROM subset WHERE (time >
> 7:13)</SrcSQL>
> I get virtually the same error as above (But with the
> other SQL syntax)
> 
> However if I replace the date value with a number like
> this: <SrcSQL>SELECT * FROM subset WHERE (time >
> 7)</SrcSQL>
> I get no points on my map but I do not get an error.

Blaine,

I am now suspecting that the problem relates to your use of unescaped
greater than and less than signs in the XML.  Try converting
your expression to something like:

  <SrcSQL>SELECT * FROM subset WHERE (ID &gt; 0) AND (ID &lt; 35)</SrcSQL>

Otherwise it is likely that the XML parser will get confused.  I still
don't understand why you are getting exactly the error message you see
though.

Best regards,

-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent




More information about the mapserver-users mailing list