Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Automatic random number on row creation

Automatic random number on row creation

From: Kuon <kuon_at_goyman.com>
Date: Thu, 29 Dec 2005 16:18:27 +0100
Message-ID: <dp0uo3$1t3$1@news.hispeed.ch>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US