Make ID unique

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
nguyenlinh111

Make ID unique

Post by nguyenlinh111 »

Hi,
How can I make the unique for the maho (Household's ID) in the form,
PROC MAHO
postproc
numeric e;
if $ = notappl then
e=display(003,"1.1.Mã số Hộ gia đình");
reenter;
endif;
if $>0 & $<=9 then
$ = tonumber(concat(matinh,mahuyen,maxa,edit("999",$)));
endif;
if $>=10 & $<=99 then
$ = tonumber(concat(matinh,mahuyen,maxa,"0",edit("99",$)));
endif;
if $>=100 & $<=999 then
$ = tonumber(concat(matinh,mahuyen,maxa,edit("999",$)));
endif;

Thanks,

Linh
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Make ID unique

Post by Gregory Martin »

Can you clarify your question? Your code appears to add several numbers to the beginning of MAHO. You might consider writing your code like this, without all of the range checks:
$ = tonumber(maketext("%d%d%d%03d",matinh,mahuyen,maxa,$));
What is your concern with making the values unique?
Post Reply