title: Calculate next Primary Key - of specific format
body: <p>I have a table which holds a list of IDs, and various other columns such as IDName.</p>
  
  <p>The Primary Key of the table is the ID itself, however it does not auto_increment.  So, I want to be able to generate / calculate the next primary key, however there is a twist:</p>
  
  <p>The primary key should be in a specific format, i.e. the 8 digit ID is made up of three parts: <br/>
  <code>&lt;the level&gt;&lt;a code&gt;&lt;a sequence #&gt;</code>, e.g. <code>&lt;2&gt;&lt;777&gt;&lt;0123&gt; = 27770123</code></p>
  
  <p>So, when I am creating a new ID for the table, I want the next sequence number for a specific level and code.  E.g. following the example above I might want to know the next sequence number for level 2 with code 777, the result should be an ID 27770124 (0124 being the next in the sequence).</p>
  
  <p>Any help would be much appreciated.</p>