1

Hi, I need to generate 6 digit random number. If I enter 10 input value then it should generate 6 digit unique random number for 10 rows. The rows that we can generate but how can we generate 6-digit integer random number using random function? Thanks

asked

Samarth Jadhav

2 answers

5

random returns a random decimal between 0 and 1. You can multiply and round the result to get a number as you need it.

What about:

round(random()*899999)+100000)

answered

Andreas Blaesius

1

For the unique you have to add a logic, that checks, if your new generated number already exists. Maybe you retrieve your generated numbers from the entity and see, if your return is ‘empty’. If true, go ahead, if false, try again. ;-)

answered

Tjark Radewaldt