Return the Object ID from the Insert Row cursor

Discussion created by npeihl on Apr 28, 2011
Latest reply on May 6, 2011 by npeihl
How can I return the object id of a row inserted with the InsertCursor? I've tried to use the script below, but it returns an error.

tbl = r"C:\temp\temp.gdb\test_table"
rows = arcpy.InsertCursor(tbl)
row = rows.newRow()
row.NAME = "TestName"

print row.OBJECTID #This returns the following error: Runtime error <type 'exceptions.RuntimeError'>: Row: Field OBJECTID does not exist

print row.NAME #This returns the same error for the NAME field even though I just set the value and the new row is definitely inserted in the table.

## I've also tried the following with no luck
print row.getValue("OBJECTID")
print row.getValue("NAME")
print row.getValue(row.OBJECTID)
print row.getValue(row.NAME)