Discussion
Last activity: 28 Jun 2016 21:54 EDT
Integer seqence in PEGA
I'm saving data in DB and I need to fill in Data.Id property type of Integer. What is the best way in Pega to generate sequence numbers?


Pegasystems Inc.
IN
Thanks, for reply. I looked through @Default.CreateUniqueID() function. It's not quite what i needed.
1) It's not sequence.
2) It's not unique. Collisions are posible. http://stackoverflow.com/questions/4881448/safe-to-use-system-currenttimemillis-to-generate-a-unique-database-id


Pegasystems Inc.
IN
@Default.GenerateID(Prefix) or @DateTime.getCurrentTimeStampUnique() be of help?
to generate sequence - we may need to get the last existing/saved list and add by ONE to form sequence...
Thanks again, seems @Default.GenerateID(Prefix) most appropriate for me.
But still don't understand why Pega uses String values as sequence? I hoped to find some encapsulation of standart DB sequence to get Integers.


IP Australia
AU
Another way to do this is, you can define your column as "Sequence" (something like that - Google for it) in your Database table. As soon as you insert record into this table, database will generate the sequence for you.
This one has few drawbacks,
- You cannot map this column to Pega property as Pega doesn't have property of type "Sequence".
- You'll have to write SQL manually to update this table
- May be you can create a view by type casting sequence to text and then have a different mapping in Pega for reading dat (not writing).
@Default.CreateUniqueID()