Trying to pull a random number that doesn't exist in a column
520215Aug 28 2007 — edited Aug 28 2007Hello,
I'm trying to generate a random number that would not exist on a column in PL/SQl on Oracle 8. For example:
Say I have a column (of integers) from 1 to 40. I have records that already exist in this table that has unique values in this column already. so it would look like this
Record_Name | Column_Value
---------------------------------------------------
Test1 | 1
Test2 | 10
Test3 | 27
Test4 | 32
Test5 | 40
Test6 | 2
All unique values......I want to be able to randomly generate a number to put into that column for a new record insert. I know that I can generate a random number by doing this:
trunc(select dbms_random.value (1,40) from dual)
But how can I tell it to not consider what already exists? Any help would be appreciated.