Package to generate random values, based on a model

I need to generate thousands of test strings based on a template (LLNNNNLL, where L stands for letter and N represents the numbers).
I was able to create, on a table, any useful combination: the next step is to get that 'good' a few tickets.

My problem is that using the following syntax I get tickets with "close to" number... just because I created using a sequence
SELECT TICKET_CODE
FROM TICKET_WELL SAMPLE (1) 
WHERE OWNER = 'OWNER_NAME'
AND rownum < 10;
I mean: AB1001CD, AC1003CB, BB1002AD...
while I need to get these tickets: AB1001CD, AC4667CD, SD8592GD etc...

First question: is there a like DBMS_RANDOM package that accepts as input a boss so I can simply replace MY package to create the TICKET_WELL table?
Second: Is there another way (right) to select a table trying to get the lines in a random order?
Third: If both answers are not... is there a way to mix the rows of a table to another?

Any suggestions are welcome.

Thank you
Marco

Here's a function I hit upwards to generate a randon number, based on an input mask.

create or replace
function random_string( p_mask           in varchar2)
return varchar2
as
v_random_number integer;
v_random_letter varchar2(1);
v_mask varchar2(20) := p_mask;
v_character varchar2(1);
v_random_string varchar2(20);
begin
for i in 1 .. length(v_mask)
loop
if substr(v_mask,i,1) = 'L'
Then
    v_random_number :=  dbms_random.value(1,26);
    v_character := chr(64+v_random_number);
elsif substr(v_mask,i,1) = 'N'
then
   v_random_number := dbms_random.value(0,9);
   v_character     := v_random_number;
end if;
v_random_string := v_random_string||v_character;
end loop;
return v_random_string;
end;

To select lines in a random order, you need to store the random number with a column, for example rowno and create an index on rowno.

create table random_rows
(rowno number,
  random_string varchar2(20)
);

then to get a random line, you can use

declare
v_rowno integer; -- must be integer
begin
v_rowno := dbms_random.value(1, v_rows_in_table);
select random_string
into v_random_string
from random_rows
where rowno := v_rowno;
end;

You can also replace the random line of the next generated random_string.
The only thing is that you can not guarantee that the random_string is unique,
If you need a unique index on the column of random_string, and he tries to insert a duplicate, you should try to insert another random number;

Tags: Database

Similar Questions

  • Generate random int with no recurrence

    Hi all

    I want to shuffle playlist and using random as possible to repeat some index of value as

    Generating random integers in the range 1..10.
    Generated : 9
    Generated : 3
    Generated : 3
    Generated : 9
    Generated : 4
    Generated : 1
    Generated : 3
    Generated : 9
    Generated : 10
    Generated : 10
    

    How to do it like this

    Generate random integers in the range 1.10.

    Generating random integers in the range 1..10.
    Generated : 9
    Generated : 1
    Generated : 3
    Generated : 8
    Generated : 4
    Generated : 2
    Generated : 5
    Generated : 7
    Generated : 10
    Generated : 6
    

    Please help me

    use http://www.blackberry.com/developers/docs/6.0.0api/net/rim/device/api/util/IntVector.html
    instead of vector.

    Remember that the numbers in the vector are the track numbers, you don't have to add anything unless you want to reset, you simply delete the number of the piece.

  • Creating a statue in gold that will generate random passwords for each deployment and how to recover passwords

    Hello

    New to 5.5 VDC and I hope that it is easy for you all the gurus.  After you create a statue in gold to say windows 2008 server and presentation in the public catalog how configure you to generate passwords random administrator when visitors in each of the ORG VDC wants to use it.  Now, I know you sysprep the OS in advance, and then when it starts, you can run the configuration wizard, or you can even define an answer file for things like the password key and administrator of the permit but y at - there a better way?  Having to go through the console and through a cloud of today technologies Assistant seems a bit old fashioned for me so I'm hoping its just something I missed narrowly in the configurations.

    The goal is simple... a customer deploys a VM and when it starts it is all ready to go so that no 2 VM This statue gold doesn't have the same credentials.  Somehow, they are provided with a generated random password to access the start new systems.  Amazon AWS for this using the keys if you deploy a virtual computer, you don't get invited to set a password... instead you can use your portal and get the password generated for you.  Their VM deployment and are ready to go without any additional configuration steps from the user at all.  How this is possible on a Director vcloud solution (or even at all).  I would like my customers to deploy from model, receive or access their new password and ready to go.  There may be a way to query the DB somehow and pull the password in this way?  And while I'm focused on windows operating system at the present time, it would be very happy to be able to do the same for root users on UNIX based as well as models.  Many big public cloud providers can provide their customers with this so I know there is a way but many also use things like openstack cloudstack or not vcloud Director.  Also I'm not familiar with the scripts so if you can get this kind of solution using scripts I'd appreciate some information or links that may describe step by step how to achieve and I will be happy to learn.  Thanks in advance

    UNIX systems are supposed to work.  And I know most the time they do.  (IE Redhat / Cent seems to work very well, however I have seen a few posts on this forum where a specific verion distribution may not work correctly.)

    Where to find the password.  Once the virtual machine boots (if the option to customize comments has been set at random) - the password will be on screen customization of comments; beside the selection of radio "Random."

    The API also has a way to get the password in case you need to expose in a different method.  (You can get it from section guestCustomize to a virtual computer in the restAPI thus).

  • Reg: Generate random integers:

    Hi Experts,

    Sorry to resurrect my old thread - https://forums.oracle.com/message/10928049

    As Frank Kulash suggested (his last message to above thread):

    As you have probably noticed, the results of discrimination 1 and 9. That's because the numbers were being rounded up or down to produce integers from 1 through 9 numbers, but none were being rounded to produce 1 and no figures have been rounded down to produce 9. A good way to use the TOWER would be

    ROUND (dbms_random.value (.5, 9.5))

    But surprisingly, I get even the values 1 and 9 to the query below:

    SELECT ROUND (Dbms_Random.Value (1.9))

    OF the double

    CONNECT BY LEVEL < = 100;


    Can any body please confirm the behavior?

    -Nordine

    (Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production)

    In order to avoid discrimination against 1 and 9 as values.

    If you have dbms_random.value (1.9) it can only generate 1.0000 to 8.9999 values.

    The tour will convert 1.00000 - 1.49999 1 and will convert 1, 5 - 2.49999 2 and so on

    until the conversion of 8.5 to 8.9999 to 9.

    As you can easily see, there are more likely to get one than a one and more likely to get

    a 8 to 9.

    If you use 0.5 to 9.5 in your random value that stop the discrimination against 1 and 9, because now

    you will get 0.5 to 1.49999 is converted to 1, etc.. The same range as 1, 5 - 2.49999 etc.

  • Column update with random values

    Hi all

    I have a chart in which one of the columns contains the number. I want to write a script that will update the column number with different random values.

    Basically, my script should take the first line of a table and should update with a random value in the second loop, it must update the column with a random value.

    I need a simple PL SQL code to do this.

    Thanks in advance.

    Thank you.

    Kind regards
    Dirasa

    or

    update table_name set column_name=round(dbms_random.value(1,100));
    

    Do not loop, this single update statement will satisfy your need by your request above.

    arguments passed in 1 100 are the lower and upper limit to generate random numbers. like 5,1,45,64,23 etc.

    Sample of run...

    PRAZY@11gR1> select * from test;
    
            ID
    ----------
             1
             2
             3
             4
             5
    
    Elapsed: 00:00:00.00
    PRAZY@11gR1> update test set id=round(dbms_random.value(1,100));
    
    5 rows updated.
    
    Elapsed: 00:00:00.00
    PRAZY@11gR1> select * from test;
    
            ID
    ----------
             2
            85
            58
            45
            27
    
    Elapsed: 00:00:00.00
    

    Kind regards
    Prazy

    Published by: Prazy on March 17, 2010 17:35

  • Generating random numbers with format 18XX88YYYYY

    I've been tryig to generate random numbers with
    format 18xx88yyyyy
    here
    18, followed by two random number then 88 followed by five random number. Here 18 and 88 are set to place one, two, five and sixth position.

    but I am unable to get the logic.

    So please help


    Thanx

    Achyot

    Try this:

    SELECT    '18'
           || ROUND (DBMS_RANDOM.VALUE (1, 100))
           || '88'
           || ROUND (DBMS_RANDOM.VALUE (1, 100000))
      FROM DUAL
    

    - - - - - - - - - - - - - - - - - - - - -
    Kamran Agayev a. (10g OCP)
    http://kamranagayev.WordPress.com

  • Generate a page based on a query variable in another page?

    Hello. I am trying to generate a page based on data from a single line in a table (not a report, such as the look of the page may be in a table). I've set up a report containing a list of all the lines where the first column consists of links; each link loads the new page and sends the value of the display of the link as a query variable.

    How to access the database without having to create a report? I think that PL/SQL and dynamic content is involved, but my knowledge in Application Express is Rusty at best.

    If you have a page parent with a report, you can create a column in the column link properties and link, you would choose an image and the elements on your page in which target you want to pass your values:

    1. report of the attributes / add column link (link on the right side)

    2. change your link column and go to the section "links in the column".

    3. choose the link image

    4. indicate your target page

    5 specify the (probably hidden) element on your page target to pass values to

    6 specify the column that contains the value of the key

    Denes Kubicek
    -------------------------------------------------------------------
    http://deneskubicek.blogspot.com/
    http://www.Opal-consulting.de/training
    http://Apex.Oracle.com/pls/OTN/f?p=31517:1
    -------------------------------------------------------------------

  • VI to convert input signals NI 9402 in a RPM value, based on the frequency of the pulses

    Hello

    I'm looking for a VI convert an input signal NI 9402 in a RPM value, based on the frequency of the pulses. Is there such a thing that exists in the library of national instruments?

    I run LAbview 2014 integrated control and monitoring on on a cRIO 9802 high performance integrated system with NEITHER 9402, 4 channels, 50 LV, LV TTL Module input/output digital, ultra high speed digital i/o for the cRIO module.

    Any help would be greatly appreciated.

    The easiest way is to use the FPGA to get the time between the edges of your pulse increase (shift registers to maintain the current situation and the time will be necessary).  This will give you the period.  If it's a single pulse per turn, then the number of laps is just 60/T, where T is the time in seconds.

  • How to generate random numbers from 1 to 5

    How to generate random numbers from 1 to 5

    -1110340081

    Thank you I ended up

  • DMA FIFO - random values?

    iHi.

    My apologies if this is the wrong Board... not sure where it should go! Just to clarify from the outset, I cannot share screws due to issues of IP etc... sigh.

    Basically I have a sbRio 9626 and the software that runs on the FPGA to interface with analog converters / digital external. This is done using a machine to States (single cycle loop timed with a structure of business inside, so it passes between cases each tick of the clock FPGA). In one of the cases (the States), I have a little routine that takes data from the ADC and place it in a buffer FIFO of DMA of target-to-host. In fact, there are 4 FIFO DMA buffers to send various information and the value of the sample. It is then read by the software on the host of RT and processed to produce an array of values which I then send to the PC using a shared variable.

    What I wanted to check, is that data sent from FPGA to RT host (and PC) are contiguous (that is, I have my right to lengths FIFO). I modified the code FPGA to use a counter instead of the data sampled for the FIFO must simply send numbers in a sequence (1, 2, 3, 4, etc.). I then examine this sequence to ensure that it is correct, and no data has been overwritten.

    I think it's the FIFOs, 2, 3 and 4 are very good. FIFO 1 sends data that is continuous but every now and then I seem to get a glitch at random. This glitch is * not * appear to be due to lengths of FIFO, but seems to be an error in the data transfer. For example, I get something like 1, 2, 3, x, 5, 6, 7, y with x and y the seemingly random values. The positions x and y in the sequence are also seemingly random - they have not held in the same place every time. Code written to the FIFO 1 is * exactly * the same thing others - in fact, it's the same group of data being written.

    Has anyone seen anything like this before? I am trying to determine if it is due to the goal to receive FIFO or some problem with the shared variable in the network. Any suggestions as to what I could check? It almost seems as if there is IME peaks on the transfer... does not suggest this is the case but it gives an idea of what I see. I'm using Labview 2013 and BIOS on the sbRio is up-to-date. I have sbRio another I'll try again later to see if the problem is specific to a particular board.

    It seems that you have found the wrong path here: since you are dealing with the programming of FPGA, which is essentially played woth LabVIEW you should post this question to the Office of LabVIEW or, perhaps, to the Office LabVIEW Embedded

  • Random values in the transmission of TCP

    Hello

    I capture a unique setting in grayscale (160 x 120) and sent via TCP to a C program. The problem is that, before the reading of the values of actual pixels in the console, the first 8 bytes is composed of some two random values "120" and "160", as shown in the image below. It seems that these two values are 32-bit unsigned integers, since each represents 4 bytes. The values come from the LabVIEW code below?

    Have you not already answered this in your original message thread?  http://forums.NI.com/T5/LabVIEW/sending-8-bit-unsigned-integer-in-LabVIEW/m-p/2695753

    That you marked as resolved?

    The one where it was mentioned that flatten chain has an entry on whether or not you want to prepend the size of tables?

    Do you really think the values of 160 and 120 'random' when in your post you mentioned even you have a table of 160 x 120?

  • values based on the following logic 'values after the first values of two '_' and before last '_' values '.

    Hi all

    I need the values according to below 2logics in a single select query using instring and substring

    1 values based on the following logic 'values after the first values of two '_' and before last '_' values '.

    2 values based on the following logic 'values after the first values of two '_' and before last'-'values '.

    EXM:

    Entry: ABCD_EFGH_IJKLM - NOPQ_XYZ output: IJKLM - NOPQ

    Entry:. ABCD_EFGH_IJKLM - NOPQ output:IJKLM

    Thank you.

    Check the following

    WITH DATA1 AS

    (SELECT "ABCD_EFGH_IJKLM - NOPQ_XYZ" double val)

    UNION ALL

    SELECT 'ABCD_EFGH_IJKLM - NOPQ' double val

    )

    SELECT SUBSTR (VAL, INSTR(VAL,'_',1,2) + 1, DECODE (BIGGER (INSTR (VAL, '_',-1, 1), INSTR(VAL,'-',-1,1)), INSTR (VAL,'-', - 1, 1), LENGTH (VAL) + 1, INSTR (VAL, '_',-1, 1))-(INSTR (VAL, '_', 1, 2) + 1))

    OF DATA1;

    Concerning

    Salim

  • Duplicate in the same random value in the composition.

    Is this possible? How can I do with expressions?

    Thank you.

    Well, nothing prevents you to just spit a random value on a global scale, then by linking all your other expressions to it. And the random() method accepts arrays as well if you want it spit only specific predetermined values. You need to read about such things. It is not still own EI, just generic JavaScript.

    Mylenium

  • Calculate values based on the boxes are checked - for Dummies...

    Hello and thank you all in advance for your help. I'm trying to calculate a value based on the boxes checked. Specifically, I would like to add a particular value $$ each CheckBox and if this box is checked, I want to add to the total rental value (see screenshot below):

    Screenshot (1).png

    As you can see in the screenshot that I have different areas that can be selected (first floor, court before, etc.), I want to assign a value to the checkbox of each region (and added value for others) and calculate a total in the "Balance of rental fees" less the deposit. I'm new with java and scripts but not know how to do it in an excel formula. I guess it's very different from what little I know of Java. Any help you can give me would be greatly appreciated.

    Calculation options are in the text field. In this screen, you only need to set the value of exports to the amount this box represents.

  • Generate random numbers in BPEL

    I have a use case that requires I generate a random number of 2 digits, something similar to "math: random * 100. I noticed that this feature is not readily available in the SOA Composite Editor. Can anyone suggest how this can be done?

    [code]

    "targetNamespace ="http://xmlns.oracle.com/KIMServices/embedded_java/BPELProcess1"

    "xmlns ="http://schemas.xmlsoap.org/ws/2003/03/business-process/"

    "xmlns:client ="http://xmlns.oracle.com/KIMServices/embedded_java/BPELProcess1"

    "xmlns:ORA ="http://schemas.oracle.com/xpath/extension"

    "xmlns:bpelx ="http://schemas.oracle.com/bpel/extension"

    "xmlns:bpws ="http://schemas.xmlsoap.org/ws/2003/03/business-process/"

    "xmlns:bpel2 ="http://docs.oasis-open.org/wsbpel/2.0/process/executable"

    "container ="http://www.w3.org/2001/XMLSchema"

    "xmlns:XP20 ="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"

    "xmlns:oraext ="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc"

    "xmlns:kimbpel ="http://xml.ibridge.nl/nl/rsg/kim/bpel"

    "xmlns:DVM ="http://www.oracle.com/XSL/Transform/java/oracle.tip.dvm.LookupValue"

    "xmlns:HWF ="http://xmlns.oracle.com/bpel/workflow/xpath"

    "xmlns:IDS ="http://xmlns.oracle.com/bpel/services/IdentityService/xpath"

    "xmlns:BPM ="http://xmlns.oracle.com/bpmn20/extensions"

    "xmlns:XDK ="http://schemas.oracle.com/bpel/extension/xpath/function/xdk"

    "xmlns:XREF ="http://www.oracle.com/XSL/Transform/java/oracle.tip.xref.xpath.XRefXPathFunctions"

    xmlns:LDAP ="http://schemas.oracle.com/xpath/extension/ldap" >. "

    Language = "java" >

    try {}

    Random random = new Random();

    int abc = random.nextInt (100);

    setVariableData ("NombrAl", abc);

    }

    end generate random number java

    [[catch (Exception e) {}]] >

    Query = "" / client: processResponse / client: result "/ >"

    [/ code]

    That should do it

Maybe you are looking for