Auto Generate primary ID using a custom prefix

Certified Senior Developer

Hello,

I would like to create a CDT with a primary key which must be an Auto-generated value but with a prefixed value. 

Ex: "APP_01",

Where the number 01 must be an auto incremented value. Is it possible to do so? If yes please suggest me a possible way to do it.

I was unable to understand the following:

Generating primary keys

When using a sequence to generate ids (such as @GeneratedValue(strategy=GenerationType.SEQUENCE)), we recommend allowing the system to name the sequence instead of providing a name with the generator attribute. If you choose to define a sequence generator with the generator attribute in conjunction with the @SequenceGenerator annotation, then you must provide a name, and that name must be unique across all sequence generators in the system to avoid uniqueness constraint violations

https://docs.appian.com/suite/help/22.2/Database_Schema_Best_Practices.html

Please help me with the above.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Keep in mind that you can expose other columns to end users and use the PK only "behind the scenes", There are pros and cons in DBs to not using integers as PKs. Relational DBs will implicitly build indexes on PKs to make lookups quicker and then whole numbers will generally be quicker and less resource consuming when querying by the PK.

Reply
  • 0
    Certified Lead Developer

    Keep in mind that you can expose other columns to end users and use the PK only "behind the scenes", There are pros and cons in DBs to not using integers as PKs. Relational DBs will implicitly build indexes on PKs to make lookups quicker and then whole numbers will generally be quicker and less resource consuming when querying by the PK.

Children
No Data