How to generate n random dates

Can anyone help me in generating Random dates, i want to generate 100 random dates in yyyy-mm-dd format.

I've tried this, but will appreciate any neat solutions...
public static void main(String arg[]) {
    int no = 0;
    while (no < 100) {
      // Year
      int yylower = 1970; // your lower integer value
      int yyupper = 2000; // the larger one of your two integers
      double rand = Math.random();
      int yyresult = yylower + (int) ( (yyupper - yylower) * rand);
      // Month
      int mmlower = 1; // your lower integer value
      int mmupper = 12; // the larger one of your two integers
      rand = Math.random();
      int mmresult = mmlower + (int) ( (mmupper - mmlower) * rand);
      // Month
      int ddlower = 1; // your lower integer value
      int ddupper = 29; // the larger one of your two integers
      rand = Math.random();
      int ddresult = ddlower + (int) ( (ddupper - ddlower) * rand);
      System.out.println(yyresult  + "-" + mmresult + "-" + ddresult);
      no++;
  }

Similar Messages

  • How to generate n random dates between 2 time periods

    Hi,
    I'm trying to write a method that generates n random dates between 2
    time periods. For example, lets say I want to generate n random dates
    between Jan 1 2003 and Jan 15 2003. I'm not sure how to go about
    doing the random date generation. Can someone provide some direction
    on how to do this?
    The method signature should look like this.
    public String[] generateRandomDates(String date1,String date2,int n){
    // date1 and date2 come in the format of mmddyyyyhh24miss.
    // n is the number of random dates to generate.
    return dateArray;
    Thanks.
    Peter

    first take a look at the API concerning a source of randomness (Random might be a good guess), then take a look at stuff concerning dates (Date might be cool, maybe you will find some links from there).
    Who wrote this stupid assignment?

  • Urgent How to generate a random code such as registration code?

    I would like to ask that how to generate a random code?
    For example, when you register a E-mail account, you need to enter the code for activation. I would like to create a java Bean to do this job. Would you help me?

    In fact, I would like to set a 10 digi codes randomly (such as FH654CS081, MKO624VG9f) for user input when they register the forum account. This random code will be sent to the user's email. User have to input this code to a JSP web site. Also, the code which is inputed by user will be matched with the database. If user input success, the forum account will be activated.
    By generating this 10 digi codes, I want to handle this generation by using java bean.
    1) Any thing else i need to import ? (such as <% page import="java.......?")
    2) Any functions can handle this task?
    3) Any example can be my reference?
    Thank you very much

  • How to generate a random session variable in php

    i want to generate a random session variable and insert the variable in a mysql record to use later to validate an account set up.
    person fills out form to create account and submits; inserts form information in mysql record.
    i want the random variable to be inserted from a hidden field and the page sends an email with a link to click on to compare the variable to validate the user.
    Not sure how to generate a random session variable and get that to the hidden field value to be inserted with the other form information.
    thanks for your help,
    Jim Balthrop

    To insert the key I would personally do something like...
    $key = md5($username . $password . $salt);
    Insert that into your MySQL database, then send them a email with it, my next code shows how to activate it.
    This is to activate the account.
    <?php
    $key;
    $errors = array();
    if(isset($_GET['key']){
         $key = $_GET['key'];
         $sql = 'SELECT * FROM users WHERE key = \'' . $key '\' LIMIT 1';
         $result = mysql_query($sql) or die(mysql_error());
         if(mysql_num_rows($result)){
              $sql2 = 'UPDATE users SET active = 1 WHERE key = \'' . $key '\' LIMIT 1';
              $result2 = mysql_query($sql2) or die(mysql_error());
              if($result2){
                   //successfully activated account
              else{
                   //Something Went Wrong!
         else{
              $errors[] = 'Invaild Key, Please try again!';
    else{
         $errors[] = 'Invaild Key, Please try again!';
    ?>

  • How to generate pseudo random noise(PRN) binary sequence using shift registers?

    what is the block diagram to generate pseudo random noise (PRN) binary sequence of 1's and 0's using shift registers
    please help
     i need 2 submit this project in this week

    This is a fairly simple homework problem. My hints (on the LabVIEW side):
    1- look at while loops
    2- look at shift registers on while loops with multiple input elements
    3-look at the logic components, AND, OR XOR
    Look at this wiki article: http://en.wikipedia.org/wiki/Linear_feedback_shift_register
    Do the work, you won't learn if someone shows you how it is done! The palette that the previous post points to are of PRN and other "noise generators" but I suspect that is not what you are after.
    Know that creating a PRN with a reasonable number of shift register taps produces very pseudo results, as the "random" pattern begins to repeat pretty quickly, thereby making it not a truly random number. 
    When you have an attempt that is sort of working and want additional suggestions, post the code here. We won't do your work, we will help you try to do it, and learn it, yourself.
    Putnam
    Certified LabVIEW Developer
    Senior Test Engineer
    Currently using LV 6.1-LabVIEW 2012, RT8.5
    LabVIEW Champion

  • How to generate a random number with at least 6 digits?

    Hi all,
    All is in the question. :-)
    I would like to generate a random number but the function "random
    number" in Labview isn't accurate enough.
    Do you know an algorithm to generate a random number of 6 or more
    digit?
    Thanks,
    PF

    Hi PF,
    It's simple. Use 2 random number functions in the same process. Now you
    should have 2 distinct random numbers that have the same accuracy. Let's say
    LV gives accuracy up to the thousandth (0.XXX), now if you divide one number
    by 1000 and then add to the other number you should then have something like
    0.XXXXXX. Actually, LV random number function can give up to about 17 digits
    (decimal). If you are looking for more digits (>17 digits), the idea above
    may not work, then the last thing you may want try is to generate two or
    three random numbers then convert all these decimal numbers to fractional
    strings chop off the 0 and dot then concatinate them together. After all
    it's still a random number. How many digits do you want to get? Make sure
    the indicators acce
    pt that many digits?
    Good luck
    Louis.
    P-F wrote in message
    news:[email protected]..
    > Hi all,
    >
    > All is in the question. :-)
    >
    > I would like to generate a random number but the function "random
    > number" in Labview isn't accurate enough.
    >
    > Do you know an algorithm to generate a random number of 6 or more
    > digit?
    >
    > Thanks,
    >
    > PF

  • How to generate I&Q data using NI5640R card?

    Hi there,
    I know how to generate a chirp using the NI5640R card (because there is a "chirp" generation function/block), But i dont know how to generate the I and Q components of the chirp. Could someone please help me with generating the I and Q components of a chirp (i.e, Can you please make a VI that generates the I and Q components of a chirp and give it to me).
    Any help regarding this will be grately appreciated.
    Thanks,
    Sandeep.
    Sandeep Palreddy, Graduate Research Assistance
    The Microwave Remote Sensing Laboratory (MIRSL)
    University of Massachusetts
    151 Holdsworth Way
    Amherst MA 01003-9284

    If the chirp signal you are generating is all real valued, there will be no Q component.

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

    I am trying to simulate data without using a DAQ device by using a random number generator and I want to be able to control the "range" of the random number generated though.  On the front pannel, the user would be able to input a nominal number, and the random number generator would generate numbers within plus or minus .003 of that nominal number.  The data would then be plotted on a graph.  Anyone know how to do this?  Or if it's even possible?
    Just for information sake, the random number is supposed to look like thickness measurements, that's why I want to simulate plus and minus .003 because the data could be thinner or thicker than the nominal.  
    Thanks in advance!!
    Solved!
    Go to Solution.

    You can create a random number with a gaussian probability profile using two equal distributed (0...1) random numbers and applying the Box Muller transform.
    I wrote one many years ago, her it is. (LabVIEW 8.0). 
    Message Edited by altenbach on 04-12-2010 09:13 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    BoxMuller.vi ‏10 KB

  • How to generate web svc data control from WSDL in 10.1.3 to secure web svc

    When I try to connect to web service via https, I get the error:
    WARNING: Unable to connect to URL: https://remove.site.com/service
    java.security.PrivilegedActionException: javax.xml.soap.SOAPException:
    Message send failed: javax.net.ssl.SSLException: SSL handshake failed:
    X509CertChainIncompleteErr Exceptionjava.rmi.RemoteException: ; nested exception is: HTTP transport error: javax.xml.soap.SOAPException:
    java.security.PrivilegedActionException: javax.xml.soap.SOAPException:
    Message send failed: javax.net.ssl.SSLException: SSL handshake failed: X509CertChainIncompleteErr
    Process exited with exit code 0.
    There does appear to be this dependency on Oracle Wallet, which I saw when I set:
    System.setProperty("HTTPClient.log.level","1");
    which showed Using Wallet:
    and nothing after it.
    AFTER I set:
    System.setProperty("javax.net.ssl.Keystore", "f:\ewallet.p12");
    System.setProperty("javax.net.ssl.KeyStorePassword","mywallet12");
    I saw the "wallet" being used, but still ended up with the same error. I'm only trying to use the "test client" that the web service "generate web service proxy" produces.
    The stack trace was:
    java.rmi.RemoteException: ; nested exception is:
         HTTP transport error: javax.xml.soap.SOAPException: java.security.PrivilegedActionException: javax.xml.soap.SOAPException: Message send failed: javax.net.ssl.SSLException: SSL handshake failed: X509CertChainIncompleteErr
         at model.runtime.ProcessOrderBinding_Stub.processOrder(ProcessOrderBinding_Stub.java:95)
         at model.ProcessOrderPortClient.processOrder(ProcessOrderPortClient.java:177)
         at model.ProcessOrderPortClient.main(ProcessOrderPortClient.java:143)
    Caused by: HTTP transport error: javax.xml.soap.SOAPException: java.security.PrivilegedActionException: javax.xml.soap.SOAPException: Message send failed: javax.net.ssl.SSLException: SSL handshake failed: X509CertChainIncompleteErr
         at oracle.j2ee.ws.client.http.HttpClientTransport.invokeImpl(HttpClientTransport.java:144)
         at oracle.j2ee.ws.client.http.HttpClientTransport.invoke(HttpClientTransport.java:120)
         at oracle.j2ee.ws.client.StreamingSender._sendImpl(StreamingSender.java:169)
         at oracle.j2ee.ws.client.StreamingSender._send(StreamingSender.java:110)
         at model.runtime.ProcessOrderBinding_Stub.processOrder(ProcessOrderBinding_Stub.java:78)
         ... 2 moreIronically, the same certificates that I loaded into the java keystore using Keytool and 10.1.2 connect to the same service without an error, using the notes as described here:
    http://andrej.racchvs.com/archives/2004/04/
    and
    http://radio.weblogs.com/0132036/2004/02/13.html
    When I created the data control for the WSDL in 10.1.2 (jdev), I didn't end up with as many files and only needed to set two system properties, and change the following lines to use Apache SOAP and I could invoke the web service as a data control as well:
    1. references to OracleSOAPHTTPConnection changed to:
    SOAPHTTPConnection
    // import oracle.soap.transport.http.OracleSOAPHTTPConnection;
    import org.apache.soap.transport.http.SOAPHTTPConnection;
    2. comment out:
    setTransportProperties
    getTransportProperties
    How can you connect to a remote web service using HTTPS with JDeveloper 10g and use the Oracle wallet?
    Can someone provide specific steps to get it working based on having a WSDL file to start with?
    Thanks!

    Hello,
    I have the same problem. I am trying to consume a CRM On Demand's Web Service from JDeveloper 10 g (version 10.1.3).
    The main method from my Client is:
    System.setProperty("HTTPClient.log.level","1");
    System.setProperty("javax.net.ssl.Keystore", "C:\\jdevstudio1013\\jdk\\jre\\lib\\security");
    System.setProperty("javax.net.ssl.KeyStorePassword",PASSWORD_KEYSTORE);
    crmod.DefaultClient myPort = new crmod.DefaultClient();
    ListOfContact list= new ListOfContact();
    ListOfContact outList= new ListOfContact();
    Contact[] contacts=new Contact[2];
    Contact contact=new Contact();
    // Login WS (HTTPS)
    idSesionFull=conexionWS_CRM.logon(constantes.URL,constantes.USER,constantes.PASSWORD);
    System.setProperty("javax.xml.rpc.service.endpoint.address", URL);
    System.setProperty("javax.xml.rpc.security.auth.username", USER);
    System.setProperty("javax.xml.rpc.security.auth.password", PASSWORD);
    System.setProperty("javax.xml.ws.BindingProvider.ENDPOINT_ADDRESS_PROPERTY", URL);
    // Add contacts
    for (int i = 0; i < contacts.length; i++) {
    contact.setContactId("WSCRM"+i);
    contact.setContactFirstName("JDeveloper"+i);
    contact.setContactLastName("prove"+i);
    contact.setCellularPhone("77777777"+i);
    contact.setExternalSystemId("1234"+i);
    contacts=contact;
    list.setContact(contacts);
    outList=myPort.contactInsert(list,"OFF");
    Contact[] results = new Contact[2];
    Contact result = new Contact();
    for (int i = 0; i < contacts.length; i++) {
    results=outList.getContact();
    System.out.println("Add contact with ID:"+results[i].getContactId()+" nom:"+results[i].getContactFirstName());
    // Logout WS (HTTPS)
    conexionWS_CRM.logoff(constantes.URL, idSesion);
    } catch (Exception ex) {
    System.out.println("error: "+ex);
    ex.printStackTrace();
    conexionWS_CRM.logoff(constantes.URL, idSesion);
    The JDeveloper's log is:
    LOGIN OK!!
    sessionString:JSESSIONID=8d928b0b231c911e83d79ff74b9eaa7795b54d784b1b.e3iRbxmNaNb0ahqLa34LbhiMe0; path=/Services; secure URL:https://secure-ausomxgfa.crmondemand.com/Services
    System.setProperty("HTTPClient.log.level","1"), print the following:
    {Thread-10} [0:50:39.15] Version: Oracle HTTPClient Version 10h
    {Thread-10} [0:50:39.46] Conn: Nagle's Algorithm is disabled
    {Thread-10} [0:50:39.46] Conn: Setting Socket Idle Timeout to 10 seconds
    {Thread-10} [0:50:39.46] Conn: Setting Maximum Authorization retries to 4
    {Thread-10} [0:50:39.62] Conn: added module HTTPClient.RetryModule
    {Thread-10} [0:50:39.93] Conn: added module HTTPClient.CookieModule
    {Thread-10} [0:50:39.93] Conn: added module HTTPClient.RedirectionModule
    {Thread-10} [0:50:39.93] Conn: added module HTTPClient.AuthorizationModule
    {Thread-10} [0:50:39.93] Conn: added module HTTPClient.DefaultModule
    {Thread-10} [0:50:39.109] Conn: added module HTTPClient.TransferEncodingModule
    {Thread-10} [0:50:39.109] Conn: added module HTTPClient.ContentMD5Module
    {Thread-10} [0:50:39.125] Conn: added module HTTPClient.ContentEncodingModule
    {Thread-10} [0:50:39.156] Conn: chunking set to true
    {Thread-10} [0:50:39.156] Conn: chunk size set to 4.096
    {Thread-10} [0:50:39.171] URLC: (https:secure-ausomxgfa.crmondemand.com:443) Setting request method: POST
    {Thread-10} [0:50:39.171] URLC: (https:secure-ausomxgfa.crmondemand.com:443) Setting request property: Content-type : application/x-www-form-urlencoded
    {Thread-10} [0:50:39.171] URLC: (https:secure-ausomxgfa.crmondemand.com:443) creating output stream
    {Thread-10} [0:50:39.171] URLC: (https:secure-ausomxgfa.crmondemand.com:443) Setting request property: SOAPAction : "document/urn:crmondemand/ws/contact/10/2004:ContactInsert"
    {Thread-10} [0:50:39.171] URLC: (https:secure-ausomxgfa.crmondemand.com:443) Setting request property: Content-Type : text/xml; charset=UTF-8
    {Thread-10} [0:50:39.171] URLC: (https:secure-ausomxgfa.crmondemand.com:443) Setting request property: Content-Length : 1173
    {Thread-10} [0:50:39.171] URLC: (https:secure-ausomxgfa.crmondemand.com:443) Connecting ...
    {Thread-10} [0:50:39.218] Conn: Creating Socket: secure-ausomxgfa.crmondemand.com:443
    {Thread-10} [0:50:39.453] Conn: using SSL version Oracle
    {Thread-10} [0:50:39.515] Using wallet:
    {Thread-10} [0:50:39.796] Conn:
    {Thread-10} [0:50:39.796] Conn: Retrying request
    {Thread-10} [0:50:39.796] Conn: Creating Socket: secure-ausomxgfa.crmondemand.com:443
    {Thread-10} [0:50:40.31] Using wallet:
    {Thread-10} [0:50:40.265] Conn:
    {Thread-10} [0:50:40.265] Conn: Retrying request
    {Thread-10} [0:50:40.265] Conn: Creating Socket: secure-ausomxgfa.crmondemand.com:443
    {Thread-10} [0:50:40.500] Using wallet:
    {Thread-10} [0:50:40.734] Conn:
    {Thread-10} [0:50:40.734] URLC: (https:secure-ausomxgfa.crmondemand.com:443) Disconnecting ...
    Unable to connect to URL: https://secure-ausomxgfa.crmondemand.com/Services/Integration due to java.security.PrivilegedActionException: javax.xml.soap.SOAPException: Message send failed: javax.net.ssl.SSLException: SSL handshake failed: X509CertChainIncompleteErr
    error: java.rmi.RemoteException: ; nested exception is:
         HTTP transport error: javax.xml.soap.SOAPException: java.security.PrivilegedActionException: javax.xml.soap.SOAPException: Message send failed: javax.net.ssl.SSLException: SSL handshake failed: X509CertChainIncompleteErr
    java.rmi.RemoteException: ; nested exception is:
         HTTP transport error: javax.xml.soap.SOAPException: java.security.PrivilegedActionException: javax.xml.soap.SOAPException: Message send failed: javax.net.ssl.SSLException: SSL handshake failed: X509CertChainIncompleteErr
         at crmod.runtime.Default_Binding_Stub.contactInsert(Default_Binding_Stub.java:506)
         at crmod.DefaultClient.contactInsert(DefaultClient.java:210)
         at crmod.DefaultClient.main(DefaultClient.java:138)
    Caused by: HTTP transport error: javax.xml.soap.SOAPException: java.security.PrivilegedActionException: javax.xml.soap.SOAPException: Message send failed: javax.net.ssl.SSLException: SSL handshake failed: X509CertChainIncompleteErr
         at oracle.j2ee.ws.common.util.exception.JAXRPCExceptionBase.<init>(JAXRPCExceptionBase.java:93)
         at oracle.j2ee.ws.common.util.exception.JAXRPCExceptionBase.<init>(JAXRPCExceptionBase.java:89)
         at oracle.j2ee.ws.client.ClientTransportException.<init>(ClientTransportException.java:33)
         at oracle.j2ee.ws.client.http.HttpClientTransport.invokeImpl(HttpClientTransport.java:144)
         at oracle.j2ee.ws.client.http.HttpClientTransport.invoke(HttpClientTransport.java:121)
         at oracle.j2ee.ws.client.StreamingSender._sendImpl(StreamingSender.java:169)
         at oracle.j2ee.ws.client.StreamingSender._send(StreamingSender.java:111)
         at crmod.runtime.Default_Binding_Stub.contactInsert(Default_Binding_Stub.java:490)
         ... 2 more
    Process exited with exit code 0.
    And I am working without Proxy Server.
    The steps I have done to obtain the keystore are:
    1) Obtain the certificate from https://secure-ausomxgfa.crmondemand.com/Services/Integration and save as .cer
    2) With this certificate I have generated the keystore:
    C:\jdevstudio1013\jdk\jre\bin keytool -import -v -f DIR_CERTIFICATE_DOWNLOADED -keystore server.keystore -keypass PASS -storepass PASS_FROM_server.keystore
    PASS=I have put an invented password
    Any idea to solve the error? Is necessary a certificate with a keystore to connect HTTPS Web Service from JDeveloper 10g?
    Thank you an regards.
    Edited by: user2349857 on 05-nov-2009 4:18
    Edited by: user2349857 on 05-nov-2009 4:25

  • How to generate unique random numbers

    Hi All,
    I am wondering whether there is already a random library or built-in function available in Java to produce some random numbers between certain ranges that are not repetitive. Let's look at a common examples as follows:
    Random diceRoller = new Random();
    for (int i = 0; i < 10; i++) {
      int roll = diceRoller.nextInt(6) + 1;
      System.out.println(roll);
    }My understanding from this approach is that it allows the same number to be repeated over and over again. However, I would like to find out how to continue generating random numbers from remaining ones that haven't been generated earlier.
    Using the above example to illustrate my intention:
    1st random number generated - possibility of 1 - 6 showed up. Say 5 is picked.
    2nd random number generated - possibility of 1, 2, 3, 4, 6 only. Say 2 is picked.
    3rd random number generated - possibility of 1, 3, 4, 6 available. Say 1 is picked.
    4th random number generated - possibility of 3, 4, 6 left. Say 6 is picked.
    5th random number generated - possibility of 3, 4 remains. Say 4 is picked.
    Any assistance would be much appreciated.
    Many thanks,
    Jack

    htran_888 wrote:
    Hi All,
    I am wondering whether there is already a random library or built-in function available in Java to produce some random numbers between certain ranges that are not repetitive. Let's look at a common examples as follows:
    Random diceRoller = new Random();
    for (int i = 0; i < 10; i++) {
    int roll = diceRoller.nextInt(6) + 1;
    System.out.println(roll);
    }My understanding from this approach is that it allows the same number to be repeated over and over again. However, I would like to find out how to continue generating random numbers from remaining ones that haven't been generated earlier.
    Using the above example to illustrate my intention:
    1st random number generated - possibility of 1 - 6 showed up. Say 5 is picked.
    2nd random number generated - possibility of 1, 2, 3, 4, 6 only. Say 2 is picked.
    3rd random number generated - possibility of 1, 3, 4, 6 available. Say 1 is picked.
    4th random number generated - possibility of 3, 4, 6 left. Say 6 is picked.
    5th random number generated - possibility of 3, 4 remains. Say 4 is picked.
    Any assistance would be much appreciated.If it is your school assignment then you have the answer above (List & the lists length).
    (You might want to look at Collections)

  • How to generate a waveform data table for my data acquisition (GPIB)?

    Hi everyone, I'm new to labview. I have a question, how to obtain waveform data(an I/O file so I can plot it in graphic software), rather than just plot a waveform graph which is pretty easy, but I want a waveform data table, how can I do that? Thank you very much!
    Message Edited by pack2themoon on 12-12-2008 10:05 PM

    Well, I would tell you how to get the data to display on a table however then you will come to another issue.
    The issue is that once the data is in a table, you cannot select all the data at once.
    You can only select one cell at a time, I'm not sure why, guess it was an oversight of some kind.
    There are a few work arounds, and if you are still interested in this aprroach, I will share them with you. 
    Cory K

  • How to generate xml using "Data Template"

    Hi,
    Can any one please tell me the steps to create xml using "Data Template".
    As per the user guide the execution method for "data Template" is "Java Concurrent Program" and the Executable mentiones is "XDODTEXE".
    But there is no information about the "execution file name" and "execution path name" which is mandatory.
    Thanks and Regards,
    Sandhya

    Hi Sandhya,
    To put a Data Template into use, you don't need to define any new executables. XDODTEXE executable is already registered in the system, as it ships with the application. The Data Template is not an executable as such, but a collection of instructions for what queries to perform and what should the resulting XML look like. XDODTEXE knows how to interpret those instructions, and produce the XML output.
    (And if you add a layout template, handle that too.)
    You do need to do the following:
    1) Create a new Data Definition (XML Publisher Administrator > Data Definitions)
    2) Upload your Data Template (remember the Code for the next step)
    3) Create a Concurrent Program that is linked to the Data Definition (Short Name = Code) (System Administrator > Program > Define)
    4) Add your Concurrent Program to a Request Group (System Administrator > Security > Responsibility > Request)
    I recommend you take a look at the XML Publisher Administration and Developer's Guide, you will find more information there.
    (http://download-west.oracle.com/docs/cd/B40089_02/current/acrobat/120xdoig.pdf)
    Best Regards & Happy New Year 2008,
    Matilda Smeds

  • I need to know how to generate a Random Multisine wave

    A Random multisine signal is defined as the superposition of a set of sine waves with random phases

    Try using "Basic Multitone.vi" or "Basic Multitone with Amplitudes.vi", with the "phase relationship" control set to random. You can find these VIs on the "functions->analyze->waveform generation" palette.

  • How to create or generate sample / test data (mass data for tables) ?

    Hello,
    I'm playing around a little with some SQL-functions, but actually I have only a small number of rows in my sample table and I would like to have "big, filled tables". :-)
    Is there an easy way to generate mass data for tables, e.g. for testing the performance of SQL-statements when a table is full of data.
    For example:
    How can I generate lets say 50.000 or 100.000 rows into a table with two columns? Is there a ready-to-use command to generate this mass of data?
    How do you create random data for testing?
    Thanks a lot in advance for your help!
    Best regards
    FireFighter

    First, thanks for the quick and great answer! It looks exactly what I'm looking for. How could I forget to look at Tom's site for such a script. ;-)
    But.....
    ...unfortunately, it doesn't seem to work. :-( And since I'm not so experienced in PL/SQL until now (looking forward to a course end of year...) I don't know what the error is. Is it not meant to use within 10g ??
    So, here is what i do:
    1. Log in to SQL*plus and generate the procedure with "@gen_data.sql"
    2. Then I try to execute the procedure by using "exec gen_data('mytesttable',500);"
    Then I get the following error output:
    SQL*plus> exec gen_data( 'mytable', 50 );
    BEGIN gen_data( 'mytable', 50 ); END;
    ERROR at line 1:
    ORA-00936: missing expression
    ORA-06512: at "SYS.GEN_DATA", line 34
    ORA-06512: at line 1
    And here is the code that I have used:
    01 create or replace procedure gen_data( p_tname in varchar2, p_records in number )
    02 authid current_user
    03 as
    04 l_insert long;
    05 l_rows number default 0;
    06 begin
    07
    08 dbms_application_info.set_client_info( 'gen_data ' || p_tname );
    09 l_insert := 'insert /*+ append */ into ' || p_tname ||
    10 ' select ';
    11
    12 for x in ( select data_type, data_length,
    13 nvl(rpad( '9',data_precision,'9')/power(10,data_scale),9999999999) maxval
    14 from user_tab_columns
    15 where table_name = upper(p_tname)
    16 order by column_id )
    17 loop
    18 if ( x.data_type in ('NUMBER', 'FLOAT' ))
    19 then
    20 l_insert := l_insert || 'dbms_random.value(1,' || x.maxval || '),';
    21 elsif ( x.data_type = 'DATE' )
    22 then
    23 l_insert := l_insert ||
    24 'sysdate+dbms_random.value+dbms_random.value(1,1000),';
    25 else
    26 l_insert := l_insert || 'dbms_random.string(''A'',' ||
    27 x.data_length || '),';
    28 end if;
    29 end loop;
    30 l_insert := rtrim(l_insert,',') ||
    31 ' from all_objects where rownum <= :n';
    32
    33 loop
    34 execute immediate l_insert using p_records - l_rows;
    35 l_rows := l_rows + sql%rowcount;
    36 commit;
    37 dbms_application_info.set_module
    38 ( l_rows || ' rows of ' || p_records, '' );
    39 exit when ( l_rows >= p_records );
    40 end loop;
    41 end;
    42 /
    Does anybody know what my error i have in here?
    Thanks again for you help in advance!
    Rgds
    FF
    Message was edited by:
    FireFighter

  • How to generate random numbers in a range?

    Hello. i am having trouble finding out how to generate a random number in a certain range. For example i have an array of 100 elements and i want to access one of the elements between 50 and 60, however i cannot find how to generate a random number between these two values.
    Thanks in advance

    java.util.Random.nextInt(int)
    Note that you can get a number between 0 and (max -
    min), exclusive. Then add min, and you've got your
    number.Obviously you didn't read this. It says to get a number between 0 and (max - min) which is actually what you did. But after that you need to add min. The first step would get a number in between 0 and 5. When you add 20 you'd get a number between 0+20=20 and 5+20=25.

Maybe you are looking for

  • How can I add a trusted site in Safari to access our secure Sharepoint site from the internet?

    My company has a secure sharepoint site that we access from the internet that requires our Active Directory logon. The Safari on the iPad does not allow you to add the URL as a trusted site and thus it prompts you for your username and password multi

  • CHANGING ORIGINAL NAME OF AN APP ANSWER QUICKMY PLS

    Hey guys I downloaded an app called Minecraft Hub. When you run it, it appears 3 site about minecraft. I changed script file and made My Sites. But the original name (appears on the left top corner) is stil Minecraft Hub. Help Me Plllleeeaaaasseee Qu

  • Select query with pivot

    Hi All, I have written a query as belows: but I dont get the output as desired. This is a with query -  I need the query output in a single record so I have pivoted the first query spl. The second set of query stk gives me the stock. My requirement i

  • Greatest value

    Hi, One of my friend has given this problem to me. I'm using 11g. Two tables t1, t2. No relation exist between these two tables. Please find the table Scripts below. -- Table t1 CREATE TABLE t1(col1 NUMBER, col2 NUMBER); INSERT INTO t1 VALUES (1,2);

  • Custom task process

    Hallo Everyone, I have a reusable workflow which is based on custom content type. In this workflow iam creating a custom Task process when a condition is satisified. This custom task process creates a new task list and create a task there but i have