Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2012

    Unanswered: Scrambling a column problem

    Hi, I am quite new to PL/SQL and Oracle. Right now I am trying to scramble all the data fields within a few columns (i.e. shuffling them, treat all these columns as a tuple)
    What I did are these
    1. Create a temp tableA with 2x number of columns and an id column as index
    2. Copy all these columns from the original table to the temp tableA (label them col1before, col2before, ...)
    3. Create a temp tableB with an id column as index
    4. Sort all these columns from the original table ordered by dbms_random.value() and copy to the temp tableB
    5. Copy all the columns from tableB to tableA (label them col1after, col2after, ...) where =
    6. Check if col1before+col2before+... == col1after+col2after+...
    7. If yes, redo from 4.
    8. If no, copy all the col1after, col2after, ... from tableA back to the original table where col1 = col1before and col2 = col2before and ...

    So far, I can achieve what I want, but I believe there must be some more efficient way such that for example
    a. I dont have to create an extra table tableB (i.e. no step 3, 5) and all the steps can be done using only tableA
    b. even better is I dont have to rely on the random sort and then check and then redo if some rows are still in place (i.e. I can just shuffle the columns in the original table)

    Please let me know any expert way to do such simple task

  2. #2
    Join Date
    Jun 2004
    Provided Answers: 1
    90% of users' problems can be resolved by punching them - the other 10% by switching off their PCs.

  3. #3
    Join Date
    Jul 2012
    Very cool info indeed! Very helpful!
    I solved my problem already, cheers

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts