Page 1 of 1

Make ID unique

Posted: June 5th, 2013, 7:09 pm
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

Re: Make ID unique

Posted: June 11th, 2013, 10:09 am
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?