Getting a Search Cursor on a sde feature class

1186
5
12-08-2010 05:36 AM
justinperez
New Contributor II
I have four feature classes in a sde database that is versioned (9.3) and I want to get a searchcursor on a specific feature class.  I keep getting the "A locator with this name does not exist." error on the feature class I want.  The other three feature classes in the database are accessible through a search cursor only the one I want is not (of course it isn't!).  Why would three of four fc's be accessible and one of the four fc's would not be accessible?  I am able to get a describe object off all the fc's just not a search cursor.  Would it be because it is being accessed by people so there is a lock?  I figure the whole database would be locked.  But if I just want a search cursor does that lock it?  Here's my code.  Thanks in advance.

##for fc in gp.listfeatureclasses():
##    print fc
##    dsc = gp.describe(fc)
##    print dsc.spatialreference.name
##    flds = gp.listfields(fc)
##    blah = flds[0].name
##    print blah
##    rows = gp.searchcursor(fc)
##    row = rows.next()
##    while row:
##        print row.getvalue(blah)
##        row = rows.next()
Tags (2)
0 Kudos
5 Replies
ChrisMathers
Occasional Contributor III
Well it isnt that it is locked. Thats the whole point of the SDE, a central database that handles data reconciliation from multiple editors. Have you tried accessing the data from outside the for loop? Try arcpy.SearchCursor with the path hard coded in and see what happens. And try it from the python windo in arcmap.
0 Kudos
ChrisSnyder
Regular Contributor III
Could it be that the misbehaving featureclass isn't versioned?
0 Kudos
justinperez
New Contributor II
I am in 9.3
I have tried to access the fc outside of the for loop and that didn't work although it did work previously in the for loop because this is code that I created a few months ago and I remember having the same trouble. 

If I can curse through the other files then why not that one.  I did a gp.testschemalock and got a false back but when I go to get a cursor on it all of the sudden the "No locator" error comes up.

The fc is versioned along with the rest of the database?  The interesting thing is that we have a "production" database which just mirrors this one that is read only for outside users and I get the same behaviour..other fc's work and this one that I need doesn't.  I also tried to curse the default version with no luck.
0 Kudos
ChrisMathers
Occasional Contributor III
Have you tried swearing instead of cursing? Sorry i had to get that out. Have you tried editing the fc in arcmap? Print the results of gp.listfeatureclasses() and see if there is an error there. It could be the returned value has a problem.
0 Kudos
justinperez
New Contributor II
Chris, I've yet to swear..louder than a murmur.  I did a gp.listfeatureclasses() and that works.  I am editing the versioned fc in arcmap as I type (or just before I typed).  I can access the fc in all other ways that I have tried except for getting a cursor on it.  I am thinking that I will need to create a workspace that isn't versioned do my *cursing* and then replace the orginal one.  Seems do-able.  Thanks.
0 Kudos