Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am still learning python and arcpy. I have spent too much time trying to figure out this code. I need help. What I have is two feature classes that have the same column names. One has older data than the other. FC1 has data that has 8 relationships (feature linked annotation). The FC2 is a master layer that gets update so attributes change. I cannot just swap fc's because the feature linked annotation is on a live web service.

I tried to use Calculate Field in an Arcmap session (found out it has to be in an edit session). I started the Calculate Field and it ran for over 20 hours and I had to kill the session. I have to update 10 columns.

I am tried to do this in Python with arcpy.CalculateField_management. Doesn't work and I posted a question. It was recommended to use cursors. The problem is I keep getting an error message that "Objects in this class cannot be updated outside an edit session [ttp.ttp.tintp_1]"

Here is my code:

import traceback
import arcpy
from arcpy import env
import os

anno_conn = "\\\\path\\Connection to database.sde"
env.workspace = anno_conn

#Variables
Table_A = "tintp_1"
Table_B = "tintp_r3"
fieldlist = ["link_id"]
workspace = os.path.dirname(anno_conn)

try:

    with arcpy.da.Editor(workspace) as edit:
        prows = arcpy.SearchCursor(Table_B)

        for prow in prows:
            prior = prow.getValue("prior_visi")
            field = prow.getValue(fieldlist[0])
            print (str(prior) +  "    " + str(field))

            rows = arcpy.UpdateCursor(Table_A, "visi_link = " + str(prior))

            for row in rows:

                row.setValue(fieldlist[0], field)
                rows.updateRow(row)
                print "updated row"

            del row
            del rows

        del prow
        del prows


except Exception, err:
        traceback.print_exc()

Any help would be greatly appreciated. This has my experienced colleagues stumped as well.

share|improve this question
    
the first thing to know is : do you have ArcEditor/ArcInfo level for being able to manipulate feature linked annotations? From your description of your problem, it seems that it comes primarily from the edition of those annotations. –  radouxju Jan 29 at 20:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.