Skip to main content
Question

How Do I Fetch the Largest Value of an Attibute, add 1, and Use It as Primary Key..

  • April 27, 2015
  • 1 reply
  • 42 views

I need to build a list of new records that have the NEXT value for an alphanumeric primary key attribute. Thus, I need to fetch the largest value ( in the form 'ADR000xxxxxxx' where "xxxxxx' is a strictly ascending list of non-zero intergers) from one feature class and populate another (temporary) feature class starting with *that* value +1 .

 

 

Thus, let's say my ADDRESS feature class has the largetst MXADDRESSCODE = 'ADR000521327'

 

And I need to create, for instance, 4 more records. So I need to fetch the above 'ADR000521327', add one to the first, making it 'ADR000521328' and continue with 'ADR000521329, 'ADR000521330, etc. in my temporary feature class named ADDR_WORK.

 

I have looked at Sorter, ExpressionEvaluator, AttributeFilter, StringConcatenator, and others, but just can't seem to turn the corner on this one.

 

 

Thanks

 

 
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.

1 reply

takashi
Celebrity
  • April 27, 2015
Hi,

 

 

Hope this procedure works as expected.

 

(1) Select a feature which has the maximum ADRESSCODE with a Sorter (Order: Descending of ADRESSCODE) and a Sampler (Sampling Type: First N Features, Sampling Amount: 1).

 

(2) Extract integer number part from the value with a SubstringExtractor (Start Index: 3, End Index: -1).

 

(3) Create the required number of copies of the feature with a Cloner. The Copy Number Attribute called "_copynum" by default will store 0-based sequential number.

 

(4) Add (@Value(_copynum)+1) to the value with an ExpressionEvaluator.

 

(5) Restore the original format ("ADRxxxxxxxxx") with a StringFormatter and a StringConcatenator.

 

 

Takashi