I am trying to generate coupen codes to provide discounts. I have tried with `Math.Random()` but I am not sure if it will assure an unique code each time ?.

Also I have tried with `dbms_random.string` utility of `Oracle' which is generating random numbers but it also does not guarantee the unique code.

Does anyone knows a good algorithm to do this ?

I am using java and oracle to develope the code.

**EDIT**: After looking few responses I would like to add that I have to store each and every generated code in the table. And the generated code should be Alphanumeric.