Select to view content in your preferred language

Using SQL CAST functionality in against a File Geodatabase

4432
10
04-19-2012 08:53 AM
DominickCisson
Regular Contributor
There are a number of references in ESRI's documentation  (http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=SQL_reference) and other threads (http://forums.esri.com/Thread.asp?c=159&f=1707&t=280410) that seem to indicate that one can use the SQL "CAST" function in a where statement against a file geodatabase to convert field types on the fly.  I'm trying to pull records based on a set of integers that begin with a particular number.  To do so, I should cast the integer field to a character, and then perform a LIKE statement against the field.  By all rights, and per documentation, the following statement should work against a File GDB: CAST("Price" AS CHARACTER) LIKE '1%'   But... it does not.  It doesn't work in ArcMap 10, and it doesn't work in 9.3  What am I doing wrong here?
10 Replies
JoshuaBixby
MVP Esteemed Contributor

You will need to build and apply the definition query outside of the GUI, e.g., ArcPy layer.definitionQuery.  The following worked for me when testing:

tbl.definitionQuery = "SpeciesWoody LIKE '%" + chr(9) + "%'"

0 Kudos