Reputation: 3
I have written query to generate a random 8 digit nummber and then i am inserting values into a table. The numbers generated should be unique.
Example: Say below is query, this generates random 8 digit number, and then i am inserting it into table temp. Now everytime before inserting into the table how do i need to check if the number generated from below query is alredy in temp table?
Using for loop doesnt seem to be useful as it will cause lag when there are going to be lot of transactions at same time. Any other suggestions like goto, if number is already in table can we use goto and then redirect it to same query until we get a unique value?
Query:
select trunc(dbms_random.value(10000000,99999999))
into v_customer_nbr
from dual;
Upvotes: 0
Views: 13298