Select to view content in your preferred language

Cursor WHERE clause selecting NULL values doesn't frickin' work

774
3
05-25-2012 11:27 AM
WilbertSoitgoes
Emerging Contributor
Hi Forum,

I've written a script that rotates rectangular index polygons based on a value in a rotation field in a FC. I walk through the original polygon FC with a search cursor, rotate each point of the polygon around its centroid and then create a new polygon object. I then APPEND this polygon to a new FC created in the beginning of the script. This all works fine and dandy.

The problem is that I want to carry over the attributes of the original polygon to the new one. I'm attempting this by opening an update cursor after the APPEND on the new polygon FC with a WHERE clause such as "ID IS NULL" and populating the new blank polygon with the previously stored attribute values. However this returns no rows. IS THIS A BUG? I've looked at the output polygon FC and it indeed has true <NULL>s in the fields (such as ID). I've tried other variants of the clause which invariably returns an "Invalid SQL Statement" every time - as it should.

I really don't want to open a cursor on the entire new FC each time and use row.isNULL(field_name) while walking through the entire thing, but if I have to I will. Is there a way to fill the polygon array or object with the fields and their values before APPENDing it to the new FC? I've looked in the docs, forums and interwebs and haven't found any examples of this method. Is it possible? Or ...

Am I doing something wrong here?

ArcGIS 10 SP4 on Windows 7 Pro

TIA, Wilbert
Tags (2)
0 Kudos
3 Replies
DarrenWiens2
MVP Alum
Why not use an insert cursor to add the polygon and attributes all at once?
0 Kudos
WilbertSoitgoes
Emerging Contributor
Why not use an insert cursor to add the polygon and attributes all at once?


Huh. Sometimes you just get so deep in the trees that you don't see the forest anymore. Thanks!

I would though, really, really like to know why I can't sub-select a NULL valued field using a WHERE clause in a cursor. It seems pretty straightforward. Again, are the cursor implementations buggy wrt NULLs?

Thanks again for the help.

Wilbert
0 Kudos
curtvprice
MVP Alum
Have you tried creating a table view with a selection expression first? Seems like that would be a more efficient way to about it anyway, as you could then do a join to your original table (assuming you  have a join item saved when you were appending the polygons to your output) and use Calculate Value to copy over the data.

Nulls can be dicey (like datetimes) as every data format stores them differently. I normally only trust them to select matches and no matches across a join.
0 Kudos