<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Return the Object ID from the Insert Row cursor in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/return-the-object-id-from-the-insert-row-cursor/m-p/424610#M33325</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Nope, as far as my attempts have gone, you can't do it (retrieve an insert cursor value like you can with an update cursor). &lt;BR /&gt;&lt;BR /&gt;So a v9.3 example:&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;insertRows = gp.insertcursor(myTable)
insertRow = insertRows.newrow()
insertRow.MYFIELD = "my value"
print insertRow.MYFIELD #THIS BOMBS!&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;It's a bug.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks, Chris. I'll submit a bug report.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 19:09:47 GMT</pubDate>
    <dc:creator>deleted-user-1T_bOHag6M8d</dc:creator>
    <dc:date>2021-12-11T19:09:47Z</dc:date>
    <item>
      <title>Return the Object ID from the Insert Row cursor</title>
      <link>https://community.esri.com/t5/python-questions/return-the-object-id-from-the-insert-row-cursor/m-p/424608#M33323</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
tbl = r"C:\temp\temp.gdb\test_table"
rows = arcpy.InsertCursor(tbl)
row = rows.newRow()
row.NAME = "TestName"
rows.insertRow(row)

print row.OBJECTID #This returns the following error: Runtime error &amp;lt;type 'exceptions.RuntimeError'&amp;gt;: 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)
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Apr 2011 21:03:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/return-the-object-id-from-the-insert-row-cursor/m-p/424608#M33323</guid>
      <dc:creator>deleted-user-1T_bOHag6M8d</dc:creator>
      <dc:date>2011-04-28T21:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: Return the Object ID from the Insert Row cursor</title>
      <link>https://community.esri.com/t5/python-questions/return-the-object-id-from-the-insert-row-cursor/m-p/424609#M33324</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Nope, as far as my attempts have gone, you can't do it (retrieve an insert cursor value like you can with an update cursor). &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So a v9.3 example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;insertRows = gp.insertcursor(myTable)
insertRow = insertRows.newrow()
insertRow.MYFIELD = "my value"
print insertRow.MYFIELD #THIS BOMBS!&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It's a bug.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:09:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/return-the-object-id-from-the-insert-row-cursor/m-p/424609#M33324</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-11T19:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: Return the Object ID from the Insert Row cursor</title>
      <link>https://community.esri.com/t5/python-questions/return-the-object-id-from-the-insert-row-cursor/m-p/424610#M33325</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Nope, as far as my attempts have gone, you can't do it (retrieve an insert cursor value like you can with an update cursor). &lt;BR /&gt;&lt;BR /&gt;So a v9.3 example:&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;insertRows = gp.insertcursor(myTable)
insertRow = insertRows.newrow()
insertRow.MYFIELD = "my value"
print insertRow.MYFIELD #THIS BOMBS!&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;It's a bug.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks, Chris. I'll submit a bug report.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:09:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/return-the-object-id-from-the-insert-row-cursor/m-p/424610#M33325</guid>
      <dc:creator>deleted-user-1T_bOHag6M8d</dc:creator>
      <dc:date>2021-12-11T19:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: Return the Object ID from the Insert Row cursor</title>
      <link>https://community.esri.com/t5/python-questions/return-the-object-id-from-the-insert-row-cursor/m-p/424611#M33326</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;BTW: this is not a new issue: &lt;/SPAN&gt;&lt;A href="http://forums.esri.com/Thread.asp?c=93&amp;amp;f=1729&amp;amp;t=293522"&gt;http://forums.esri.com/Thread.asp?c=93&amp;amp;f=1729&amp;amp;t=293522&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Apr 2011 22:11:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/return-the-object-id-from-the-insert-row-cursor/m-p/424611#M33326</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2011-04-28T22:11:24Z</dc:date>
    </item>
    <item>
      <title>Re: Return the Object ID from the Insert Row cursor</title>
      <link>https://community.esri.com/t5/python-questions/return-the-object-id-from-the-insert-row-cursor/m-p/424612#M33327</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;BTW: this is not a new issue: &lt;A href="http://forums.esri.com/Thread.asp?c=93&amp;amp;f=1729&amp;amp;t=293522"&gt;http://forums.esri.com/Thread.asp?c=93&amp;amp;f=1729&amp;amp;t=293522&lt;/A&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Again, thanks. I'll try the workaround posted at the bottom of that thread and hold out hope that it'll be a bug that is fixed quickly.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Apr 2011 22:17:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/return-the-object-id-from-the-insert-row-cursor/m-p/424612#M33327</guid>
      <dc:creator>deleted-user-1T_bOHag6M8d</dc:creator>
      <dc:date>2011-04-28T22:17:02Z</dc:date>
    </item>
    <item>
      <title>Re: Return the Object ID from the Insert Row cursor</title>
      <link>https://community.esri.com/t5/python-questions/return-the-object-id-from-the-insert-row-cursor/m-p/424613#M33328</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It would seem logical (but perhaps incorrect) to assume that the row(s) you are inserting will always have ordered and consecutive OID values relative to any existing OID values in the table. So, if inserting rows into an empty table, logically your fist inserted row would be OID = 1 (OID = 0 if a shapefile/dbf). Similarly, if inserting rows into a table with existing records (last existing one ending in OID = 222), then your first inserted row would be OID = 223. Note that the insertcursor method does not have a sort order parameter, so no chance for that messing with an otherwise orderly universe. So maybe a faster/better work around would be prior to running an insert cursor, run a searchcursor to grab the largest existing OID value, and in your insertcursor, start counting at that number.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Apr 2011 22:28:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/return-the-object-id-from-the-insert-row-cursor/m-p/424613#M33328</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2011-04-28T22:28:24Z</dc:date>
    </item>
    <item>
      <title>Re: Return the Object ID from the Insert Row cursor</title>
      <link>https://community.esri.com/t5/python-questions/return-the-object-id-from-the-insert-row-cursor/m-p/424614#M33329</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;hope that it'll be a bug that is fixed quickly&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;:rolleyes:&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Apr 2011 22:39:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/return-the-object-id-from-the-insert-row-cursor/m-p/424614#M33329</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2011-04-28T22:39:47Z</dc:date>
    </item>
    <item>
      <title>Re: Return the Object ID from the Insert Row cursor</title>
      <link>https://community.esri.com/t5/python-questions/return-the-object-id-from-the-insert-row-cursor/m-p/424615#M33330</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This was filed as a bug by ESRI. The number is #NIM067843.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 May 2011 21:46:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/return-the-object-id-from-the-insert-row-cursor/m-p/424615#M33330</guid>
      <dc:creator>deleted-user-1T_bOHag6M8d</dc:creator>
      <dc:date>2011-05-06T21:46:13Z</dc:date>
    </item>
  </channel>
</rss>

