Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1189
  • Last Modified:

Update rows with random number....

Hello All,
    I'm trying to update a column in a table, with about 1000 rows, with a randon string.
This is what i tried....

update tab1 set col1 = (select dbms_random.string('X', 5) from dual)

This doesnt seem to work..   its not getting a new random number.
Is there a simple solution.
Appreciate your time.
0
queryanalyzer
Asked:
queryanalyzer
  • 4
  • 2
1 Solution
 
actonwangCommented:
update tab1 set col1 = dbms_random.string('U',5)
/
0
 
actonwangCommented:
>>update tab1 set col1 = (select dbms_random.string('X', 5) from dual)
 
    if you do this, dbms_random will only execute once for all columns.

      :)
0
 
queryanalyzerAuthor Commented:
Ok..   that look simple.
I ended up trying something like this...

update tab1 t1 set t1.col1 = (select dbms_random.string('X', 5) from dual, tab1 t2 where t1.pk = t2.pk)

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
actonwangCommented:
You just need to use my query if you just want some random strings.
0
 
actonwangCommented:
why do you need dual to come into play in your case? I don't think you need dual there.
0
 
paquicubaCommented:
update ( SELECT col1, dbms_random.string('X', 5) STRING from TAB1) SET COL1 = STRING;
0
 
queryanalyzerAuthor Commented:
actonwang,
     You are right i dont need it.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now