Generate random number and letter in a text field ...

Hi All,
I having a bit trouble when trying to generate random number and letter in application express in a text field. Say I have a licence form and when user wants to create a licence, it will provide a random licence number in the licence number field but it has to be unique. the number should be something like HQ2345. I was trying to set the following sql in default value for that text field but it is not working -
select DBMS_RANDOM.STRING('',2) || trunc(DBMS_RANDOM.VALUE(1000,9999))
from dual;
any suggesion !!!!
thanks

Put this as default value for your text-item
DBMS_RANDOM.STRING('',2) || trunc(DBMS_RANDOM.VALUE(1000,9999))
with type PL/SQL Expression. It have tested it and it works fine.
DickDral

Similar Messages

  • How can I create a random number and letter in a text field...

    Hi All,
    I am using application express. I want to get a random number and letter for a text field but not sure how to do this. Say I have a licence form and I want to get the licence number automatically when user wants to create a new licence and it needs to be unique. The format I am looking for is - HQ2631 something like this.
    I am thinking I have to create a trigger but not sure how to go about this....
    advanced thanks,
    Tajuddin

    Something to play with:
    Your method can generate 26 * 26 * 10000 different licence_ids
    Generating one million ids takes 20 seconds but produces between 70000 and 80000 duplicates and is rapidly getting worse (if that is something over 7%, doubling the ids generated that grows to something under 30%)
    Just see if you can live with that.
    select sum(collisions) all_duplicates,count(*) distinct_duplicates,max(collisions) max_multiple
      from (select licence_id,count(*) - 1 collisions
              from (select DBMS_RANDOM.STRING('',2) || trunc(DBMS_RANDOM.VALUE(1000,9999)) licence_id
                      from dual
                     connect by level <= :to_generate
             group by licence_id
             having count(*) > 1
           )Regards
    Etbin

  • Generate a random number and make it STAY after "save"

    I searched around this forum and found that I can use this code to generate a random number:
    //this.rawValue = Math.round(Math.random() * 1000000);
    Works great. only problem is, once I practice on the "real" form and save, close, and reopen - it changes the random number every time. I need to figure out a way to make it save the 1st number it generates when someone opens the form and types info in it....then they save and close, etc.
    Can anyone help me? Thanks!!

    Example steps:
    1. Add a hidden field to the same subform with name 'hiddenField'.
    2. First time you open 'hiddenField' rawValue will be null.
    3. where ever you run the code to generate random number use scenario like this.
    if (hiddenField.isNull) {
    this.rawValue = Math.round(Math.random() * 1000000);
    }else {
    this.rawValue = hiddenField.rawValue;
    Hope this thelps.
    SekharN

  • Generate Random number at VB6

    Thank you for reading below scenario:
    assume user will input 4 digits number to a text
    Input Number : 1119
    and I'll create a command button, after click on the command button it will generate above number
    Generate : 1119
    1191
    1911
    9111
    I did using "Randomize" but it generate the same number as result... .Can anyone give me an idea how to generate random number using Visual Basic as the above scenario?
    Thank's a lot

    The first thing to do is to rewrite in PHP.
    -- CJ

  • How to judge whether the chars contain only number and letter

    how to judge whether the chars contain only number and letter, for example :
    'AEs4386' is valid , but '‘´‘¼ew78' is not
    thanks for your help !

    Hi,
    try the following:
    data: l_test(36) type c.
    concatenate sy-abcde '0123456789' into l_test.
    l_test contains all letters all numbers now
    translate YourVariable to upper case.
    YourVariable contains only upper case letters
    check YourVariable co l_test. " or use if instead of check
    YourVariable contains only letters or numbers
    regards
    Siggi

  • HT5556 Hi ! I have a problem whit my iTunes card . I scratch the cod but is been of also the number and letter so I can't activate any more that card . Can you help me please to find the good code . Thank you

    Hi ! I have a problem whit my iTunes card . I scratch the cod but is been of also the number and letter so I can't activate any more that card . Can you help me how to fiind the good code  please  Thank you

    Click here and request assistance, supplying as much of the code as you can.
    (74543)

  • Populate a drop down list with data from Excel and fill in a text field, based on drop down selectio

    Hi!
    I have a problem with a PDF form: There's a drop down list that I populate with Excel data that I've put in an XML file through an XSD file -- no problem here. The drop down list has a data binding to the XML file, so that a choice in the drop down list can be associated with an object in the XML file. So, when I make a choice in the drop down list, a corresponding object value is fetched from the XML file and put in a text field on the form.
    How to do this is described by Stefan Cameron here:
    http://forms.stefcameron.com/2006/07/29/dynamic-properties/
    There's a snag, though, and to describe it more clearly:
    The XML file contains three types of objects: role, role number, and role cost center. Of these I use the first and the third, i.e. the role and the role cost center. The drop down list contains the roles, and when I select a role, the corresponding cost center is filled out in the text field. So far, so good!
    But -- if the cost center has the same value for two or more roles, all of these roles "bounce back" into the drop down list, that is, they are all selected in the drop down list. How many of these you can see depend on the height of the drop down list -- if it's low you'll only see the first one.
    If I modify Stefan Cameron's data in his example I get the same behavior, so the problem seems to have to do with how XML data are fetched.
    I'm sure there's a workaround, but I can't find it! I've spent many hours browsing the web without finding anyone with a similar problem.
    Any suggestions appreciated!

    Although your issue is far beyond mine, I was hoping you can help me out.....
    I need to create a drop down list of names which I wish to somehow link to an Excel spreadsheet.
    Please let me know the steps I need to do.  I've tried several things, but nothing seems to work and I'm not sure what I am doing wrong.
    Thank you

  • I am creating a request for proposal form and I need to add a commission structure field.  I created a table using the ranking field and now I need to delete the "dots/buttons" and turn them into text fields, is this possible?

      I created a table using the ranking field and now I need to delete the "dots/buttons" and turn them into text fields, is this possible?

    It sounds like what you are trying to do is edit the choices in a likert field to something other than the default radio button. This is not something that you can do in Formscentral at this time.
    Andrew

  • Need help with a JavaScript to generate random number

    Hi
    First things first. I don't know the J of JavaScript.
    When I was thinking of some readymade solution to generate a random number in Captivate, I found this on a LinkedIn forum.
    1) Add a user variable to your project called "randomNumber". It's value can be zero.
    2) Add a Text Caption with "$$randomNumber$$" in it, to check whether your script is working.
    3) Add a button to the slide. Give it an On Success Action of Execute JavaScript. Turn off it's "Continue Playing the Project" checkbox.
    4) Add the following text in the button's Script_Window:
    var objCP = document.Captivate;
    var rand = 1 + Math.floor(Math.random() * 10);
    function onButtonClick(){
    objCP.cpEISetValue('randomNumber', rand);
    onButtonClick();
    However, this is (as the poster in the forum warned) not working for Captivate 7. Can somebody please help?
    I am open for any other methods of getting the same result.
    Thanks in advance,
    Sreekanth

    Hi Sreekanth,
    When testing, make sure you are testing from a web server where the web address begins with http or https.  When setting the captivate variable "randomNumber" try this instead:
    objCP.cpEISetValue('m_VarHandle.randomNumber', rand);
    That will only work for SWF output.  If you want it to work for both HTML5 and SWF output, try this code:
    window.onButtonClick = function(){
              var rand = generateRandomNumber(1, 10);
              setCpVariable('randomNumber', rand);
    window.generateRandomNumber = function(min, max){
              var randomNum = 0;
              if(!isNaN(parseFloat(min)) && !isNaN(parseFloat(max))){
                        min = Number(min);
                        max = Number(max);
                  randomNum = Math.floor(Math.random() * (max - min + 1)) + min;
              return randomNum;
    window.setCpVariable = function (cpUserVariableName, variableValue) {
              /* Check for HTML5 vs. SWF output */
              if (typeof window.cp === 'undefined') {
                        /* We have SWF output, so Get the Captivate Object */
                        var objCp = document.getElementById('Captivate');
                        if (objCp && objCp.cpEISetValue) {
                                  /* Set the Captivate User variable with the JavaScript variable, variableValue */
                                  objCp.cpEISetValue('m_VarHandle.' + cpUserVariableName, variableValue);
              } else {
                        /* We have HTML5 output */
                        /*If variable does not exist off of the window object, then use the variables manager*/
                        if (typeof window[cpUserVariableName] === 'undefined') {
                                  if (cp.vm && cp.vm.setVariableValue) {
                                            cp.vm.setVariableValue(cpUserVariableName, variableValue);
                        } else {
                                  window[cpUserVariableName] = variableValue;
    window.onButtonClick();
    Be sure to test this from a web server or else local security will prevent the javascript from executing.
    Best,
    Jim Leichliter

  • Generate random number

    hi,
    can anybode give an example code
    how to generate a random number
    something like this:
    RandomData ran=RandomData.getInstance(...)
    byte[] ranString=JCSystem.makeTransientByteArray(...
    ran.generateData....
    and by the way can someone explain which line to put in which part of the code
    can I simply display this on a phone's screen with DisplayText proactive command ?
    regards
    Kuba

    i'm using Gemplus GXXv3 cards.
    And I'd like to display random data on the phone's screen using DISPLAY TEXT toolkit command.
    I just wonder if I have to convert the generated data somehow.
    Or can I just generate a byte array and display it using initDisplayText command.
    Kuba

  • Is there any way to generate random number in CPO

    Requirement : -
    > I want  to generate a random number from set of 1-9 numbers .is there any way in cpo ?
    Thanks
    Siva

    I created a process that uses 3 steps, all of which happen inside the engine rather than having to span out to a script, so it runs a lot faster.
    Technically, it's pseudo-random...
    Predefine Output Variable "Random Number" as type "Numeric"
    Step 1:  Format Date
      Format string: fffffff 
        (that's seven lower-case letters "f")
      Original date: [Process.Start Time]
    Step 2: Format Date
      Format string: ff\0\0\0\0\0
      Original date: [Process Start Time]
    Step 3: Set Variable
      Variable to update: [Process.Variables.Output.Random Number]
      New value: ([Workflow.Format Date.Formatted Date]-[Workflow.Format Date (2).Formatted Date])/100000
    This returns a basically random number between 0 and 1 (so you can mulitply it by your maximum value) based on the numeric fraction of a second of the start time of the process.

  • Updating a field that generates random number when form is reset..

    I have a field that will generate a random number when the form is initially opened. THis fiekd runs an initialization script of : var randomnumber=Math.floor(math.random()*99999) and then a calculation script of randomnumber.
    The field value is set as Calculated - Read Only.
    When I hit the Reset button and it clears all the input fields for the form i would like to have it re calculate a new random number. I am not knowledgable in any scripting language and what I have so far I found by searching the forums.
    Any help would be appreciated.
    Thanks

    I don't know if it should matter, but the field to update is on a page other than the one with the reset button. And, the above is not working.
    I tried it as you stated above fieldname.rawvalue=randomnumber and I tried pagename.fieldname.rawvalue=randomnumber

  • How to generate random number

    Hi I am trying to generate a random number between 0 to 100. Anyone know how to do this. I know we can use the Random class, but I don't know how to implement it between 0 and 100.
    Thanks

    XPOST:
    http://forum.java.sun.com/thread.jsp?forum=31&thread=547130&tstart=0&trange=15
    http://forum.java.sun.com/thread.jsp?forum=31&thread=547129&tstart=0&trange=15

  • Generating Random Number in NumberGuessing Game

    hi.. thankds for taking time to read this. please tell me how genNum works?
    public static void genNum followed by what coding? i have no idea. if possible please provide me with the necessary coding. thanks.

    I have never headr of genNum. If you want random numbers you want the following.....
    public class randomIntGenerator{
      private static long myRandom;
      private static long myMaximum;
      public static int getRandom(int maxValue){
        // Math.random() generates a random number between
        // 0 and 1.
        myRandom = Math.random();
        // To do the math you need your maximum as a long.
        myMaximum = new Long(maxValue).longValue();
        // multiply them together, then get the int value
        // and return it.
        return (new long(myRandom * myMaximum).intValue());
    }

  • Generating random number within size of map problem (why me!!) ?

    Hi Guys,
    I'm trying to generator random numbers between 0 and a map width and another random number between 0 and a map height i.e if the map width was 3 i can generator 0,1,2.
    The coding i am using to do this is :
    int randomCol;
    int randomRow;
    randomCol = newMapWidth - 0 + 1;
    int itemp = generator.nextInt() % randomCol;
    if (itemp < 0)
          itemp = -itemp;
    randomCol = 0 + itemp;
    randomRow = newMapHeight - 0 + 1;
    int jtemp = generator.nextInt() % randomRow;
    if (jtemp < 0)
         jtemp = -jtemp;
    randomRow = 0 + jtemp;I've had a look at similar problems and searched penalty but can't seem to get it right for whatever way i implement. It leads to some array out of bound errors.
    If any can help me resolve this problem it would be greatly appreciated.
    Thanks A lot !

    Hippolyte wrote:
    randomRow = 0 + jtemp;I'll bite: what's the "0 + " voodoo for?It?s for clarity and Code readability, I guess. @OP: Random.nextFloat() generates numbers from 0.0f to 1.0f. Multiplying this number with your max value will generate a number between 0 and that given max value. BTW, you can generate numbers from -a to a by using (Random.nextFloat()- .5f) * (2 * a).
    Shazaam.

Maybe you are looking for

  • Increase counter frequency performanc​e

    Hello, I want to increase the frequency performance for my period counter. I'm using a USB-6210 board and I have the vi that is attached - period measurement. The problem is that I want to measure the period for a 8MHz signal (I know that is a lot, I

  • Is there a way to change the iCloud account on my iPhone from one email to another without deleting the first account or deleting the information currently on my phone?

    Right now my iCloud is synced through our family Apple ID. It wasn't a problem until my mom got an iPad and synced it to the same Apple ID, so now she receives all of my iMessages and FaceTime messages. I have created my own Apple account, but how do

  • Printing with black ink only

    I have a HP photosmart c6280.  I only want to print in black only but my colored ink keeps expiring and needs to be replace too frequently.  I have tried grayscale but it still drains my color ink.  what can be done about this?????

  • Help! Yoga 8 - how to remove page?

    Can anyone teach me how to remove extra page from the Yoga-8 launcher? before 4.4.2, I can remove a page by holding the page -> display the pages, then click on the X sign on the page to delete the page; but now I couldn't see that X, so no way to re

  • MDX in NW

    Having a problem with dimension formula in SAP BPC for NW 7.0 sp8: Scenario 1: Account A5010a_I = A507_I is written as [A507_I] in the column formula in the account dimension. Works just fine. Scenario 2: Account  A5010a_I = A507_I for Periodic is wr