<?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: Postgres: next_rowid implement in ArcGIS Enterprise Questions</title>
    <link>https://community.esri.com/t5/arcgis-enterprise-questions/postgres-next-rowid-implement/m-p/278558#M10650</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Note: This was incorrectly marked as answered&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 30 Sep 2019 19:38:00 GMT</pubDate>
    <dc:creator>RobertMueller2</dc:creator>
    <dc:date>2019-09-30T19:38:00Z</dc:date>
    <item>
      <title>Postgres: next_rowid implement</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/postgres-next-rowid-implement/m-p/278557#M10649</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Related to my question here (&lt;A href="https://community.esri.com/thread/239876" target="_blank"&gt;postgres nonversioned editing - sequence vs next_rowid&lt;/A&gt;&amp;nbsp;) on returning the next_rowid for non-versioned Postgres database (&lt;SPAN style="background-color: #ffffff;"&gt;Postgres 10.6/PostGIS 2.2), I'm trying to implement the next_row id (&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/10.6/manage-data/using-sql-with-gdbs/next-rowid.htm" title="http://desktop.arcgis.com/en/arcmap/10.6/manage-data/using-sql-with-gdbs/next-rowid.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Next_RowID—Help | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;) with an insert trigger, however I'm buffaloed on how to get this done. Hoping someone has done this before.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;When I run a basic next_rowid select in PgAdmin, I get response I'm looking for (where 'data' is the schema and 'newtest_point2' is the table)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;SQL:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;select&lt;/SPAN&gt; sde&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;next_rowid&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'data'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'newtest_point2'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return: 481&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;Postgres documentation (&lt;A class="link-titled" href="http://www.postgresqltutorial.com/creating-first-trigger-postgresql/" title="http://www.postgresqltutorial.com/creating-first-trigger-postgresql/" rel="nofollow noopener noreferrer" target="_blank"&gt;Creating PostgreSQL Trigger Example&lt;/A&gt;&amp;nbsp;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;Function:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;CREATE&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;OR&lt;/SPAN&gt; REPLACE &lt;SPAN class="keyword token"&gt;FUNCTION&lt;/SPAN&gt; test_trigger_func&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
 &lt;SPAN class="keyword token"&gt;RETURNS&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;trigger&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;AS&lt;/SPAN&gt;
$BODY$
&lt;SPAN class="keyword token"&gt;BEGIN&lt;/SPAN&gt;
   &lt;SPAN class="comment token"&gt;#insert into data.newtest_point2 (objectid)&lt;/SPAN&gt;
   &lt;SPAN class="comment token"&gt;#Values (sde.next_rowid('data', 'newtest_point2'));&lt;/SPAN&gt;
   new&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;objectid&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sde&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;next_rowid&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'data'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'newtest_point2'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
 
 &lt;SPAN class="keyword token"&gt;RETURN&lt;/SPAN&gt; NEW&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;END&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
$BODY$
 
LANGUAGE plpgsql&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;Trigger:&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class="" style="color: #445870; border: 0px; font-weight: 500; font-size: 13px; padding: 0px 5px 0px 30px;"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;CREATE&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;TRIGGER&lt;/SPAN&gt; test_trigger
BEFORE &lt;SPAN class="keyword token"&gt;Insert&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;ON&lt;/SPAN&gt; newtest_point2
    &lt;SPAN class="keyword token"&gt;FOR EACH ROW&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;EXECUTE&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;PROCEDURE&lt;/SPAN&gt; test_trigger_func&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV class="" style="color: #445870; border: 0px; font-weight: 500; font-size: 13px; padding: 0px 5px;"&gt;&lt;/DIV&gt;&lt;DIV class="" style="color: #445870; border: 0px; font-weight: 500; font-size: 13px; padding: 0px 5px;"&gt;&lt;/DIV&gt;&lt;DIV class="" style="color: #445870; border: 0px; font-weight: 500; font-size: 13px; padding: 0px 5px;"&gt;&lt;P style="color: #3d3d3d; font-weight: 400; padding: 0px;"&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV class="" style="border: 0px; font-weight: 500; font-size: 13px; padding: 0px 5px 0px 35px;"&gt;&lt;/DIV&gt;&lt;DIV class="" style="border: 0px; font-weight: 500; font-size: 13px; padding: 0px 5px;"&gt;&lt;DIV class="" style="color: #445870; border: 0px; font-weight: 500; font-size: 13px; padding: 0px 5px;"&gt;&lt;SPAN style="background-color: #ffffff; color: #3d3d3d; font-weight: 400; font-size: inherit !important;"&gt;&lt;SPAN&gt;However my error (when adding creating points in ArcPro) :&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="" style="color: #445870; border: 0px; font-weight: 500; font-size: 13px; padding: 0px 5px;"&gt;&lt;SPAN class="" style="color: #006fe0 !important; font-weight: inherit !important; font-size: inherit !important;"&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="" style="border: 0px; font-weight: 500; font-size: 13px; padding: 0px 5px 0px 35px; text-align: left;"&gt;&lt;SPAN style="background-color: #ffffff; color: #3d3d3d; font-weight: 400; font-size: inherit !important;"&gt;&lt;SPAN&gt;&lt;IMG __jive_id="459544" class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/459544_pastedImage_662.png" /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="" style="border: 0px; font-weight: 500; font-size: 13px; padding: 0px 5px 0px 35px; text-align: left;"&gt;&lt;/DIV&gt;&lt;DIV class="" style="border: 0px; font-weight: 500; font-size: 13px; padding: 0px 5px; text-align: left;"&gt;&lt;SPAN style="background-color: #ffffff; color: #3d3d3d; font-weight: 400; font-size: inherit !important;"&gt;&lt;SPAN&gt;I found a somewhat similar post on another forum (&amp;nbsp;&lt;A class="link-titled" href="https://stackoverflow.com/questions/28084086/postgis-trigger-function-max-stack-depth-reached" title="https://stackoverflow.com/questions/28084086/postgis-trigger-function-max-stack-depth-reached" rel="nofollow noopener noreferrer" target="_blank"&gt;postgresql - PostGIS Trigger Function -- max stack depth reached - Stack Overflow&lt;/A&gt;&amp;nbsp;,) but haven't figured out the solution.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="" style="border: 0px; font-weight: 500; font-size: 13px; padding: 0px 5px; text-align: left;"&gt;&lt;/DIV&gt;&lt;DIV class="" style="border: 0px; font-weight: 500; font-size: 13px; padding: 0px 5px; text-align: left;"&gt;&lt;SPAN style="background-color: #ffffff; color: #3d3d3d; font-weight: 400; font-size: inherit !important;"&gt;&lt;SPAN&gt;Anyone have any suggestions or run into this before with implementing a insert trigger on next_rowid?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="" style="border: 0px; font-weight: 500; font-size: 13px; padding: 0px 5px; text-align: left;"&gt;&lt;SPAN style="background-color: #ffffff; color: #3d3d3d; font-weight: 400; font-size: inherit !important;"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="" style="border: 0px; font-weight: 500; font-size: 13px; padding: 0px 5px; text-align: left;"&gt;&lt;SPAN style="background-color: #ffffff; color: #3d3d3d; font-weight: 400; font-size: inherit !important;"&gt;&lt;SPAN&gt;Note - I thought modifying back the trigger to "update" rather than "insert" did the trick, but it only appeared to work with an existing sequence.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="" style="border: 0px; font-weight: 500; font-size: 13px; padding: 0px 5px; text-align: left;"&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:33:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/postgres-next-rowid-implement/m-p/278557#M10649</guid>
      <dc:creator>RobertMueller2</dc:creator>
      <dc:date>2021-12-11T13:33:33Z</dc:date>
    </item>
    <item>
      <title>Re: Postgres: next_rowid implement</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/postgres-next-rowid-implement/m-p/278558#M10650</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Note: This was incorrectly marked as answered&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Sep 2019 19:38:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/postgres-next-rowid-implement/m-p/278558#M10650</guid>
      <dc:creator>RobertMueller2</dc:creator>
      <dc:date>2019-09-30T19:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: Postgres: next_rowid implement</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/postgres-next-rowid-implement/m-p/278559#M10651</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Figured it out - for all those that may need this solution in the future (also fixed in the original)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Replace these 2 lines:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;insert into data.newtest_point2 (objectid)&lt;/SPAN&gt;&lt;BR style="background-color: #ffffff;" /&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;values (sde.next_rowid('data', 'newtest_point2'));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;With:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;new.objectid= sde.next_rowid('data', '&lt;SPAN&gt;newtest_point2&lt;/SPAN&gt;')&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;Check with insert (in PgAdmin for Postgres)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;insert into data.newtest_point2 (shape)&lt;BR /&gt; &amp;nbsp;&amp;nbsp;values ('ST_GeomFromText('POINT(-71.060316 48.432044)', 4326))&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Oct 2019 13:49:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/postgres-next-rowid-implement/m-p/278559#M10651</guid>
      <dc:creator>RobertMueller2</dc:creator>
      <dc:date>2019-10-02T13:49:38Z</dc:date>
    </item>
  </channel>
</rss>

