Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Automatic random number on row creation
Hello,
I have a ticket system which need a random (act as a password) string generated. But this string also act as a key (need to be unique).
The approach of the former dev does not suites me.
He was generating a random string, doing a select key where key = ... To verify the uniqueness of the key.
If the select returned nothing, he inserted the new row.
Of course this is not good, for many reasons.
I want to do it database side.
I know something like that:
select dbms_random.string('U', 20) str from dual
for my random number.
But how, when I do:
insert into myTable (otherInfos) values ("myotherinfos"),
how can the "key" column been automaticaly assigned a random and unique string?
Then I can select this column and pass it in my app.
Thanks a lot
Regards
Kuon Received on Thu Dec 29 2005 - 09:18:27 CST
![]() |
![]() |