Saviynt unveils its cutting-edge Intelligence Suite products to revolutionize Identity Security!
Click HERE to see how Saviynt Intelligence is transforming the industry.
Saviynt Copilot Icon

SystemUsername generation using advanced sql query

priyag
New Contributor
New Contributor

Hello all 

need a help for  generating  the StemUserName according to the following conditions.All lower case, remove diacritics <firstname>.<lastname>[<xxx>] Limited to 20 characters, if necessary truncate last name ,Uniqueness, In case of duplicate, append 3 digits starting with 001 and incrementing as needed. 

 

2 REPLIES 2

NM
Honored Contributor II
Honored Contributor II

Hi @priyag , 

Case when (select count(*) from users u where u.syatemusername like concat(lower(u.firstname),'.',substring(lower(u.lastname),1,20),'001')=0 then concat(lower(u.firstname),'.',substring(lower(u.lastname),1,20),'001')

Else 

concat(lower(u.firstname),'.',substring(lower(u.lastname),1,20),(select substring_index(substring(u1.susystemusername,1,(length(u1.firstname)+length(substring(u1.lastname,1,20)),'@',1)+1 from users u1 where u1.systenusername like concat(u1.firstname,substring(u1.lastname,1,20))),'@abc.com') END