Unique random number

Hello

Oracle 11.2.0.1

Windows

I have a table something like this:

create table (ID, number of rnd) rnd;

I need a process something like this:

exec genrnd (200,300);

After executing the procedure, there will be 100 lines in the table of rnd and there will be unique random numbers in the column of rnd.  OK, suppose if I run once again something like this:

exec genrnd (173,514);

therefore table will be truncated and (514-173) + 1 = 342 lines will be rnd table and new unique random numbers will be in the column of rnd.

Column ID is just at the end of the order of.  There will be 1,2,3... 100 or 1,2,3,4... numbers 342.

I get random number in this way:

Select trunc (dbms_random.value (200,300)) rnd twice;

Select trunc (dbms_random.value (173,514)) rnd twice;

but number must be unique within the given range, so I don't get how this is possible, please help me.

Thank you.

Insert into rnd

Select rownum, one of

(

Select * from

(

Select rownum + start_value - 1A

Double connect rownum<= end_value="" -="" start_value="" +="">

)

order of dbms_random.value

);

This query has 4 parts

(1) generation X Y numbers in order

(2) randomized data generated

(3) assign a rownum for each row of data

(4) Insert the result in the table

So he adapts to the requirements of the opus and don't know how

> Order by on the insert does nothing

available in photo with this code.

Tags: Database

Similar Questions

  • 5 digit unique random number based on the year

    Hello
    I need 5 digit unique random number based on the year. If the new year then duplicate random number allowed.
    Thank you

    If only 5-digit numbers are needed you can extract some transformation injective (http://en.wikipedia.org/wiki/Injective_function) and you could easily check for uniqueness:
    substr (to_char (ln (sequence_value)), 10, 5)
    substr (to_char (exp(1 / sequence_value)), 20, 5)
    ...

    Concerning

    Etbin

  • Generating unique random number with a Boolean signal on an RT target

    Hello, this is my first time asking your question. I apologize if I post this question in the wrong Council.

    [What I'm trying to do]

    I am stable heating and cooling in an experimental space that I (with cRio9024).

    And I'm putting a different experimental condition in space based on the function 'random number '.

    'Different experimental conditions' sense different combinations of Tind, Twat_s and mdot (refer to the attached VI).

    For example, if I get the Boolean TRUE signal.

    I should have a set of [Tind, Twat_s, mdot] = [21,14,0.05], and IS this set of numbers until this Boolean signal goes to FALSE.

    And when the signal passes to the TRUE once again.

    I should have a different set of [Tind, Twat_s, mdot] = [24,16,0.15] for example.

    [I]

    Problem I am with my code is that,

    When the VI is running, the random number remains the same as the Boolean signal is set to TRUE.

    From what I tried so far for the last couple days, using 'the event structure' was the message more concerned that I found,

    However, LabView help tells me that "structure of the event" on the objectives of the RT do not support the events associated with the user interface such as the façade of VI or controls panels.

    I would therefore ask a quick help, since my knowledge of LabView is exhausted at this point.

    This is so the part where I want to generate random numbers, WHEN this structure case is TRUE.

    convert whole numbers, random numbers

    Use them as a table index,

    while I can choose conditions from radom to the given set of conditions.

    Once more, I want to do is,

    generate a SINGLE random number series when the structure above is TRUE.

    Hope I have developed quite clear.

    I'm appreciated for any kind of advice.

    Thank you!

    You just need to store the Boolean from the previous run. Then the logic would be (I'll call her Boolean previous B_prevand current boolean B):

    If B AND B_prev > don't generate new values

    otherwise if B > generate new values

    Edit: to store your Boolean value, you can use a feedback node, or a loop with N = 1 and a registry change.

  • How to generate a single random number in a MySQL database

    I create a volunteer and also a separate request form from the seller for an air show. The volunteer and seller info is stored in separate tables in MySQL db, a line by volunteer or the seller. There will be about 100 volunteers and 50 sellers. When the request should immediately be printed by the applicant signed and mailed in. This year we had problems with some people who do not immediately print asked, so I would still give them the possibility to print immediately, but also to send them an email with a link to their specific line in the MySQL database. I have an AutoIncrement primary key for each table field, but I think to send this key to the applicant in an email would be too easy for them to guess a different id and access the information of others.

    I think I should add a column for each table containing a unique random number and then I would send this key in the e-mail to the applicant. So, can anyone suggest a simple way to do this or suggest a better way to give the applicant a way to access their own request and nobody elses not after submitting their form?

    Thank you all.

    Tony Babb

    In your code, you should:

     VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, $s)",
    

    Change the $s to %s and that should solve the problem for you.

    Let me know.  Thank you!

    Chad

  • Effective unique random numbers

    Hi all

    I'm looking for assign a random number from 1-20 from 20 different variables. I need each variable to have a unique number. Later, I put variables into a list, and because of the randomly generated number that the list is in a different order each time the program is run. What I have works, but I think it's bulky. I was wondering if there was a better way to do this. Thank you:

    Here is an excerpt of how I am the procedure, which shows the process for the first 10 variables, but the last 10 follow the same pattern:

    N1 = Math.floor (Math.random () * 20) + 1;

    questionRandomizer1 ();

    questionRandomizer2 ();

    questionRandomizer3 ();

    questionRandomizer4 ();

    questionRandomizer5 ();

    questionRandomizer6 ();

    questionRandomizer7 ();

    questionRandomizer8 ();

    questionRandomizer9 ();

    questionRandomizer10 ();

    questionRandomizer11 ();

    questionRandomizer12 ();

    questionRandomizer13 ();

    questionRandomizer14 ();

    questionRandomizer15 ();

    questionRandomizer16 ();

    questionRandomizer17 ();

    questionRandomizer18 ();

    questionRandomizer19 ();

    questionRandomizer20 ();

    function questionRandomizer1)

    {

    QuestionOrder [1] = n1;

    }

    function questionRandomizer2)

    {

    QuestionOrder [2] = Math.floor (Math.random () * 20) + 1;

    If (QuestionOrder [2] == QuestionOrder [1]) {questionRandomizer2 ()}

    }

    I'm generates a random number to QuestionOrder [2], then check if it is the same number as QuestionOrder [1], and in this case, I'm re - run the function to generate a random number again, until he gets a unique number. This continues for each next function.

    function questionRandomizer3)

    {

    QuestionOrder [3] = Math.floor (Math.random () * 20) + 1;

    If (QuestionOrder [3] == QuestionOrder [1] |) QuestionOrder [3] == QuestionOrder [2]) {questionRandomizer3 ()}

    }

    function questionRandomizer4)

    {

    QuestionOrder [4] = Math.floor (Math.random () * 20) + 1;

    If (QuestionOrder [4] == QuestionOrder [1] |) QuestionOrder [4] == QuestionOrder [2] | QuestionOrder [4] == QuestionOrder [3]) {questionRandomizer4 ()}

    }

    function questionRandomizer5)

    {

    QuestionOrder [5] = Math.floor (Math.random () * 20) + 1;

    If (QuestionOrder [5] == QuestionOrder [1] |) QuestionOrder [5] == QuestionOrder [2] | QuestionOrder [5] == QuestionOrder [3] | QuestionOrder [5] == QuestionOrder [4]) {questionRandomizer5 ()}

    }

    function questionRandomizer6)

    {

    QuestionOrder [6] = Math.floor (Math.random () * 20) + 1;

    If (QuestionOrder [6] == QuestionOrder [1] |) QuestionOrder [6] == QuestionOrder [2] | QuestionOrder [6] == QuestionOrder [3] | QuestionOrder [6] == QuestionOrder [4]

    || QuestionOrder [6] == QuestionOrder [5]) {questionRandomizer6 ()}

    }

    function questionRandomizer7)

    {

    QuestionOrder [7] = Math.floor (Math.random () * 20) + 1;

    If (QuestionOrder [7] == QuestionOrder [1] |) QuestionOrder [7] == QuestionOrder [2] | QuestionOrder [7] == QuestionOrder [3] | QuestionOrder [7] == QuestionOrder [4]

    || QuestionOrder [7] == QuestionOrder [5] | QuestionOrder [7] == QuestionOrder [6]) {questionRandomizer7 ()}

    }

    function questionRandomizer8)

    {

    QuestionOrder [8] = Math.floor (Math.random () * 20) + 1;

    If (QuestionOrder [8] == QuestionOrder [1] |) QuestionOrder [8] == QuestionOrder [2] | QuestionOrder [8] == QuestionOrder [3] | QuestionOrder [8] == QuestionOrder [4]

    || QuestionOrder [8] == QuestionOrder [5] | QuestionOrder [8] == QuestionOrder [6] | QuestionOrder [8] == QuestionOrder [7]) {questionRandomizer8 ()}

    }

    function questionRandomizer9)

    {

    QuestionOrder [9] = Math.floor (Math.random () * 20) + 1;

    If (QuestionOrder [9] == QuestionOrder [1] |) QuestionOrder [9] == QuestionOrder [2] | QuestionOrder [9] == QuestionOrder [3] | QuestionOrder [9] == QuestionOrder [4]

    || QuestionOrder [9] == QuestionOrder [5] | QuestionOrder [9] == QuestionOrder [6] | QuestionOrder [9] == QuestionOrder [7] | QuestionOrder [9] == QuestionOrder [8]) {questionRandomizer9 ()}

    }

    function questionRandomizer10)

    {

    QuestionOrder [10] = Math.floor (Math.random () * 20) + 1;

    If (QuestionOrder [10] == QuestionOrder [1] |) QuestionOrder [10] == QuestionOrder [2] | QuestionOrder [10] == QuestionOrder [3] | QuestionOrder [10] == QuestionOrder [4]

    || QuestionOrder [10] == QuestionOrder [5] | QuestionOrder [10] == QuestionOrder [6] | QuestionOrder [10] == QuestionOrder [7] | QuestionOrder [10] == QuestionOrder [8]

    || QuestionOrder [10] == QuestionOrder [9]) {questionRandomizer10 ()}

    }

    as you can see the checklist gets progressively longer. I feel that I do a ton of If, Then, Else statements, and usually when this happens I will use a system of records. IM wondering if there is a better way to do it, in the same way a case statement is more effective than a bunch of If, then, Else statements.

    Thank you.

    Just create an array with 20 values in either randomly select them (and then splice), or probably even better, just mix table and retrieve ordered items randomly in the order they come.

    Here is a function for the table of brewing in AS3:

    function shuffle(a:Array) {}
    var p:int;
    var t: *;
    var ivar:int;
    for (ivar =. Length-1; Ivar > = 0; Ivar-) {}
    p = Math.Floor ((Ivar+1) * Math.Random ());
    t = a [ivar];
    a [ivar] = a [p];
    a [p] = t;
    }
    }

    Use:
    Shuffle (anArray);

  • Virus on iPhone to clicking on a link. Compound random number several times. What should I do?

    I clicked on a link on Twitter, and then on this site, he asked to check my browser compatibility. When I click on this box he started numbering to a random number and several times. I got calls as fast I have could and also turned my phone works, but I'm afraid that my information may be compromised. What should I do? Thanks to help from there.

    Nothing to do.

    Do not click on those in the future.

    You can't catch a virus like this.

  • How can I generate a single random number on a button for use in a VI?

    I'm creating a new VI and need a new random number every time that I hit a button... it will eventually be replaced by externally triggered en boolean, but for now, I would like to just press a button, get a new number, use this number, click the button, get a new number (previous deletion), etc etc.

    Thank you

    -Steve

    Just to add to what SAM has shown you can generate in a different ranges without limit it... It's just a very simple logic... Try this...

  • How can I create a random number generator, protected by password and username?

    I have attached a VI that is a random number generator. I want to just be prompted for the name of user and password when I start this generator. There should be three names of users and passwords found in three different files. I would like to know how to link the code username/password for the code generator and how do the program to know that there are three txt files in my computer with usernames and passowrds.


  • How to build a VI that generates a random number between 1 and 80... Help!

    Generate a VI that generates a random number between 1 and 80

    Divide the random number by a number specified in the front panel.

    If the number of seizures is zero, the VI program should light a LED in the face to indicate a divide by zero error.

    Hai edwardty2009,

    Welcome to the forum.

    Thanks for the congratulations.

    Your problem is solved? If so can you please mark as solution what post help better to solve your problem.

    Thank you

    Mathan

  • How to generate a random number within a specified tolerance and control than tolerance.

    I am trying to simulate data without using a data acquisition device using a random number generator and I want to be able to control the "range" the random number generated well.  On the front panel, the user can enter a nominal number, and the random number generator would generate numbers more or less disponibles.003 this number nominal.  The data would be delayed on a chart.  Someone knows how to do this?  Or if it is still possible?

    Just for the sake of information, the random number is supposed to resemble thickness measures, that's why I want to simulate more and less disponibles.003 because the data might be thinner or thicker than the nominal value.

    Thanks in advance!

    Two ways of approaching the issue.  First of all, for even distribution, you can 'Roll the dice', which is the (0,1) random number function, multiply the result by 0.06 and then add Mean - 0.03 to center around average distribution.  If you simulate a real process, my initial guess would be that the results would follow a normal distribution.  In this case, you can use the VI of white noise Gaussian of the palette of generation of signals with a standard deviation of 0.015 if you wanted 0.03 to be the point of 2 sigma, then add average results.

  • Random number

    Hello

    I want to build the app to get a random number between 200 and 250

    How can I do in labview

    nots I have labview 9

    Thank you

    Random numbers in LabVIEW function generates a number between 0 and 1.  Multiply it by 50 and then add 200.  If you only need integers, then convert it in full at the end.

  • How can I generate multiple unique random numbers?

    Hello

    I am trying to generate multiple random numbers between a given set of numbers (1-52) and do not have the same number generated twice within this group. I can compare the numbers of last and next with the function to compare, but how would I go about comparison of all numbers generated without using a huge list of shift registers...

    Any help/ideas are welcome and appreciated.

    Jason

    Solved my problem. IM passing the random number through a registry to offset to each case and build a table every time. I then searches the table for the new random number. If the number is not found I get a value of-1, another thing is an index value of 0-everything. If a comparator greater than (-1) indicates that the same number is in the table and then I can raise this matter until the same number is not found.

    Kind regards

    Jason

  • Error message: "the temp"e:\random number\cygwin\tmp\"directory is not a valid directory. Cannot install Visual C++ express 2010.

    Original title: cannot install visual c++ express 2010.

    When I ran vc_web.exe, I got this error message: "the temp"e:\random number\cygwin\tmp\"directory is not a valid directory. Implementation cannot continue. "Can help to solve this problem? Thank you.

    Hi moyeh,

    The question you have posted is better suited to the MSDN forums. You can ask your question in the help link.

    http://social.msdn.Microsoft.com/forums/en/Vsexpressvc/threads

    Hope the helps of information.
    Please post back and we do know.

  • Generate a random number

    I have this function to generate a random number

    RandNum = genRand();

    public function genRand (): int
    {
    Return (Math.Random ());
    }

    but he seemed to generate the number is 0

    any1 have more luck with this?

    Hey,.

    According to the range of numbers you're trying to get it, you must either change the type returned or modfiy before he returned. What happens is the number that you generate is probably something like 0.9393 (example) and his cutting the comma because you return a value type int value (no decimals).

    try to modify the function to do this:

    public function genRand():int
            {
                return(Math.random() * 10);
            }
    

    and you will get a number from 0 to 10. If you want a number from 0 to 100, you can use 100 instead of ten, and so on. This will give you back not decimal numbers. If you want decimal numbers simply change the type of data returned to the number instead. hope that helps. Good luck!

  • Smartphones from blackBerry Desktop Manager software - random number generator

    Hello

    I have a blackberry that I configured to synchronize with an outlook account. The other day when it is plugged, I received a message that pops up saying something about a "random number generator '. When I searched the problem of people said to uninstall/reinstall the Desktop Manager software with the latest version. So I downloaded the latest version of the software, and when I ran everything has been disabled. When I uninstall/reinstall the version that we used before the same thing, everything has been disabled. This could be the cause of this problem? I guess it must be a hardware problem.

    Thank you for your time.

    Reid

    Hi and welcome to the forums!

    I recommend you to perform the following procedure

    to ensure that you have removed all the system

    the files and registry entries made by previous installations.

    Make sure that all antivirus and firewalls are down when you install

    The other two links will help check connection problems.

    Bifocals

    Don't forget to adjust your thread.

    Put the check mark in the green box containing your answer! Thank you

    Own installation procedure;

    http://www.BlackBerry.com/BTSC/search.do?cmd=displayKC&docType=kc&externalId=KB02206&sliceId=SAL_Pub...

    Assistance Fund

    http://www.BlackBerry.com/BTSC/search.do?cmd=displayKC&docType=kc&externalId=KB00125&sliceId=SAL_Pub...

    Troubleshooting USB connection:

    http://www.BlackBerry.com/BTSC/search.do?cmd=displayKC&docType=kc&externalId=KB02640&sliceId=SAL_Pub...

Maybe you are looking for