Skip to main content
Question

I have an Id field in a table & need to add the max id + 1 to a new set of features with the same field name

  • November 3, 2015
  • 4 replies
  • 48 views

I have an Id field in a table & need to add the max id + 1 to a new set of features with the same field name
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

4 replies

takashi
Celebrity
  • November 3, 2015
You can use the StatisticsCalculator to get the maximum value of the Id field. However, I'm unclear what the next requirement is. Where will the "new set of features" come from?

pratap
Contributor
Forum|alt.badge.img+12
  • Contributor
  • November 3, 2015
Yes, StatisticsCalculator + ExpressionEvaluator will address this

  • Author
  • November 3, 2015
Thanks, The second table is a subset that need the new id so that when I place them back into the first non spatial table the numbers are unique. The non spatial table will have entries from table 2 and table 3.

takashi
Celebrity
  • November 3, 2015
A possible way is:

 

get the maximum value of Id in the first table with a StatisticsCalculator,

 

merge the "max Id" to the subset features unconditionally with a FeatureMerger,

 

then add Id starting with (max Id + 1) to the features using a Counter.

 

e.g.

 

 

To merge "Id._max" to the subset features unconditionally, set an identical constant value (e.g. 1) to the Join On parameter for both Requestor and Supplier.

 

 

If the first table was stored in a database, you can also use the SQLCreator or SQLExecutor to get the maximum Id value efficiently with a SQL statement like this.

 

select max(Id) as maxId from first_table;