<?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: Reiterate Database Sequence in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/reiterate-database-sequence/m-p/1291852#M919</link>
    <description>&lt;P&gt;I don't use database sequences because I got tired of the "gaps" in the sequence whenever a feature got created, but not saved, etc.&lt;/P&gt;&lt;P&gt;SQL server can easily script the drop/create of the database sequence.&amp;nbsp; No example (and haven't tested), but one option would be to put an insert trigger on the table and check if the number has reached 999999, if so, drop/re-create the sequence.&lt;/P&gt;&lt;P&gt;You can follow the image below to see how to have SSMS create the drop/create SQL for you:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RhettZufelt_0-1684789701473.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/71353i7F91136DC64B90B2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RhettZufelt_0-1684789701473.png" alt="RhettZufelt_0-1684789701473.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 22 May 2023 21:11:01 GMT</pubDate>
    <dc:creator>RhettZufelt</dc:creator>
    <dc:date>2023-05-22T21:11:01Z</dc:date>
    <item>
      <title>Reiterate Database Sequence</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/reiterate-database-sequence/m-p/1291782#M918</link>
      <description>&lt;P&gt;Hello all.&lt;/P&gt;&lt;P&gt;Does anyone know if it is possible to reiterate a database sequence upon reaching a specified cap/maximum?&lt;/P&gt;&lt;P&gt;We have it coded in SQL to create unique FacilityIDs for our assets with the format: "&amp;lt;AssetPrefix&amp;gt;_DDMMYYYY_&amp;lt;6-digit number&amp;gt;".&lt;/P&gt;&lt;P&gt;I would like for the last 6 numbers to reset to the initial starting point of the Database Sequence in use upon the sequence breaching the number 999999.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found some walk-throughs on how to put this together in Arcade using the CreateDatabaseSequence gp with the exception of being able to reset the value of the Database Sequence.&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2023 18:58:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/reiterate-database-sequence/m-p/1291782#M918</guid>
      <dc:creator>drWood</dc:creator>
      <dc:date>2023-05-22T18:58:01Z</dc:date>
    </item>
    <item>
      <title>Re: Reiterate Database Sequence</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/reiterate-database-sequence/m-p/1291852#M919</link>
      <description>&lt;P&gt;I don't use database sequences because I got tired of the "gaps" in the sequence whenever a feature got created, but not saved, etc.&lt;/P&gt;&lt;P&gt;SQL server can easily script the drop/create of the database sequence.&amp;nbsp; No example (and haven't tested), but one option would be to put an insert trigger on the table and check if the number has reached 999999, if so, drop/re-create the sequence.&lt;/P&gt;&lt;P&gt;You can follow the image below to see how to have SSMS create the drop/create SQL for you:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RhettZufelt_0-1684789701473.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/71353i7F91136DC64B90B2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RhettZufelt_0-1684789701473.png" alt="RhettZufelt_0-1684789701473.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2023 21:11:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/reiterate-database-sequence/m-p/1291852#M919</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2023-05-22T21:11:01Z</dc:date>
    </item>
    <item>
      <title>Re: Reiterate Database Sequence</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/reiterate-database-sequence/m-p/1291857#M920</link>
      <description>&lt;P&gt;You can't use Arcade to reset the sequence, but you can do it without a sequence:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Calculation Attribute Rule
// field: FacilityID
// triggers: insert

// get the feature that was created last
var fs = Filter($featureset, "FacilityID IS NOT NULL")
var last_f = First(OrderBy(fs, "OBJECTID DESC"))
if(last_f == null) { return $feature.FaciltyID }

// get its sequence value
var old_seq = Number(Split(last_f.FacilityID, "_")[-1])

// get the new sequence value
var new_seq = IIf(old_seq + 1 &amp;gt; 999999, 1, old_seq + 1)

// construct and return the new FacilityID
var s = Text(new_seq, "000000")
var d = Text(Today(), "DDMMY")
return `ABC_${d}_${s}`&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 22 May 2023 21:25:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/reiterate-database-sequence/m-p/1291857#M920</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-05-22T21:25:14Z</dc:date>
    </item>
  </channel>
</rss>

