Alphanumeric sequence 0001 to ZZZZ (basic No 36)

Hi friends,

I need to create a sequence of 4 digits from 0001 to ZZZZ numners. It might be

0001

0002

0003

....

9999

A000

A001

A002

....

A999

B000

B001

B002

....

Z999

AA00

AA01

AA02

....

AA99

AB00

AB01

....

AZ99

AAA1

....

ZZZZ

I just many sons and other instances, AskTom, Tkyte, etc. But I don't have the answer. Most of the responses are Base 36. But my requirement is decimal based.

If the input is "1" then the output should be "0001" input '999', output "0999; Enter "9999", exit "9999." entry "10000", exit "A000"; 10001 entry, exit "A0001". and so on.

Thanks in advance.

This is an expanded version. It ranges from your specifications in this AZ99 is followed by BA00 instead of AAA1. I have also determined the letters use of SUBSTR () ing in a list rather than use CHR(). This gives you the possibility of missing some letters - O and I, for example. Just remove the letters you want to not letter_pool. It might be interesting to remove all vowels, thereby minimizing the chance that your code number contains all the rude words.

Anyway, here's my effort:

Alpha_encode (p_num in NUMBER) of the FUNCTION to CREATE or REPLACE RETURN VARCHAR2 IS DETERMINISTIC

code VARCHAR2 (4);

letter_pool VARCHAR2 (26): = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

letter_ct NUMBER: = LENGTH (letter_pool);

-Easier to start working on the digital beaches

NUMBER of boundary_x999: = 10000;  -Beginning of the 999 codes x

NUMBER of boundary_xx99: = boundary_x999 + (letter_ct * 1000);

NUMBER of boundary_xxx9: = boundary_xx99 + (letter_ct * letter_ct * 100);

boundary_xxxx NUMBER: = boundary_xxx9 + (letter_ct * letter_ct * letter_ct * 10);

boundary_top NUMBER: = boundary_xxxx + (letter_ct * letter_ct * letter_ct * letter_ct);

letter_part NUMBER;  -Part of the number to be encoded as a letter

BEGIN

IF p_num< 0="" or="" p_num="" !="TRUNC(p_num)" then   ="" --="" not="" a="" positive="">

RAISE value_error;

ELSIF p_num< boundary_x999="" then                     ="" --="" straight="">

Code: = TO_NUMBER (p_num 'fm0000');

ELSIF p_num< boundary_xx99="" then ="" --="">

letter_part: = TRUNC ((p_num-boundary_x999)/1000);

Code: = SUBSTR (letter_pool,

letter_part + 1,

1)

|| SUBSTR (to_char (p_num),-3);

ELSIF p_num< boundary_xxx9 ="" then ="" --="">

letter_part: = TRUNC ((p_num-boundary_xx99)/100);

Code: = SUBSTR (letter_pool,

TRUNC(letter_part/letter_ct) + 1,

1) ||

SUBSTR (letter_pool,

MOD (letter_part, letter_ct) + 1,

1) ||

SUBSTR (to_char (p_num),-2);

ELSIF p_num< boundary_xxxx ="" then ="" --="">

letter_part: = TRUNC ((p_num-boundary_xxx9)/10);

Code: = SUBSTR (letter_pool,

TRUNC (letter_part /(letter_ct*letter_ct)) + 1,

1) ||

SUBSTR (letter_pool,

MOD (TRUNC(letter_part/letter_ct), letter_ct) + 1,

1) ||

SUBSTR (letter_pool,

MOD (letter_part, letter_ct) + 1,

1) ||

SUBSTR (to_char (p_num),-1);

ELSIF p_num< boundary_top ="" then ="" --="">

letter_part: = p_num-boundary_xxxx;

Code: = SUBSTR (letter_pool,

TRUNC (letter_part /(letter_ct*letter_ct*letter_ct)) + 1,

1) ||

SUBSTR (letter_pool,

MOD (trunc (letter_part /(letter_ct*letter_ct)), letter_ct) + 1;

1) ||

SUBSTR (letter_pool,

MOD (TRUNC(letter_part/letter_ct), letter_ct) + 1,

1) ||

SUBSTR (letter_pool,

MOD (letter_part, letter_ct) + 1,

(1);

ON THE OTHER

RAISE value_error;  -Number is greater than the able to face coding

END IF;

RETURN code;

END;

Tags: Database

Similar Questions

  • Alphanumeric sequence numbers generator

    How to generate an alphanumeric sequence number in oracle?

    Like this:
    0000
    0001
    0002
    ......
    9999
    A000
    A001
    A002
    .....
    A999
    B000
    B001
    B002
    .....
    .....
    Z999
    AB00
    AB01
    AB02
    .....

    I forgot to say, if you want to wrap back to 0000 when it reaches ZZZZ, then you will need to mod the first element of 36 too...

    SQL> ed
    Wrote file afiedt.buf
    
      1  with b36 as (select '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' as b36 from dual)
      2      ,num as (select rownum+1679600 as num from dual connect by rownum <= 50)
      3  --
      4  select num.num,
      5         substr(b36.b36, mod(trunc(num.num/(36*36*36)),36)+1, 1)||
      6         substr(b36.b36, mod(trunc(num.num/(36*36)),36)+1,1)||
      7         substr(b36.b36, mod(trunc(num.num/36),36)+1,1)||
      8         substr(b36.b36, mod(num.num,36)+1,1)
      9* from num, b36
    SQL> /
    
           NUM SUBS
    ---------- ----
       1679601 ZZZL
       1679602 ZZZM
       1679603 ZZZN
       1679604 ZZZO
       1679605 ZZZP
       1679606 ZZZQ
       1679607 ZZZR
       1679608 ZZZS
       1679609 ZZZT
       1679610 ZZZU
       1679611 ZZZV
       1679612 ZZZW
       1679613 ZZZX
       1679614 ZZZY
       1679615 ZZZZ
       1679616 0000
       1679617 0001
       1679618 0002
       1679619 0003
       1679620 0004
       1679621 0005
       1679622 0006
       1679623 0007
       1679624 0008
       1679625 0009
       1679626 000A
       1679627 000B
       1679628 000C
       1679629 000D
       1679630 000E
       1679631 000F
       1679632 000G
       1679633 000H
       1679634 000I
       1679635 000J
       1679636 000K
       1679637 000L
       1679638 000M
       1679639 000N
       1679640 000O
       1679641 000P
       1679642 000Q
       1679643 000R
       1679644 000S
       1679645 000T
       1679646 000U
       1679647 000V
       1679648 000W
       1679649 000X
       1679650 000Y
    
    50 rows selected.
    
    SQL>
    
  • How to generate the alphanumeric sequence under oracle

    Hi Experts,

    I need to create a primary key as below,

    Its should start from a001, a002... a100 after reaching 100 the next value in the sequence must begin by b001... b100, like wise the sequence should go through until summer z001 alphabet... z100.

    Please let me know for any information.

    Kind regards

    Millar

    This will generate the a1 - a100, b1 - b100,... z1 - z100, aa1 - aa100, ab1 - ab100,... az1 - az100,...

    SEQUENCE of s FALL

    /

    CREATE SEQUENCE s

    /

    CREATE OR REPLACE

    FUNCTION get_s_nextval

    RETURN VARCHAR2

    IS

    number of v_nextval;

    number of v_alpha;

    number of v_number;

    v_base26 varchar2 (100);

    BEGIN

    v_nextval: = s.nextval;

    v_number: = MOD(v_nextval,100) CASE

    WHEN 0 THEN 100

    Of OTHER MOD(v_nextval,100)

    END;

    v_alpha: = CEIL(v_nextval / 100) - 1;

    v_base26: = NULL;

    LOOP

    v_base26: = CHR (ASCII ('a') + MOD(v_alpha,26)) | v_base26;

    EXIT WHEN v_alpha<>

    v_alpha: = TRUNC(v_alpha / 26) - 1;

    END LOOP;

    RETURN v_base26 | LPAD (v_number, 3, '0');

    END;

    /

    WITH t AS)

    SELECT s get_s_nextval,

    level lvl

    OF the double

    CONNECT BY level<=>

    )

    SELECT s

    T

    WHERE MOD(lvl,100)<=>

    ORDER BY lvl

    /

    S
    ------------------
    A001
    A100
    B001
    B100
    C001
    C100
    D001
    D100
    E001
    E100
    F001

    S
    ------------------
    F100
    G001
    G100
    H001
    H100
    I001
    i100
    J001
    J100

    20 selected lines.

    SQL >

    SY.

  • Understand the choice of sequence

    Well, I figured out how I'm going to name my pictures. But now I'm trying to understand these choices of sequences that are:

    1 sequence # (1).

    2 sequence # (01).

    3 sequence # (001).

    4 sequence # (0001).

    5 sequence # (000001).

    These options correspond to how many files Lightroom will be the maximum number of? Like saying I chose sequence # (1). If I had only nine pictures I'd be correct since Lightroom will count from 1 to 9. But as I add image number 10 while I'm in trouble cuz I ran out of digits?

    So basically if you choose # (1) you can have up to 9 images (ten if you start numbering at 0) before running out of numbers.

    If you choose # (01), you can have up to 99 images before you start running out of numbers.

    If you choose # (001), you can have up to 999 images before you start running out of numbers.

    I understand that correctly?

    No, this isn't how it works. The format Specifies how many zeros will be added to the number if the number itself is not all figures.

    Examples:

    Image #.
    #(1) #(01) #(001) #(0001)
    1 1 01 001 0001
    2 2 02 002 0002
    ... ... ... ... ...
    9 9 09 009 0009
    10 10 10 010 0010
    11 11 11 011 0011
    ... ... ... ... ...
    99 99 99 099 0099
    100 100 100 100 0100
    ... ... ... ... ...
    999 999 999 999 0999
    1000 1000 1000 1000 1000

    The sequence number referred number of images within the import, which means that it will be reset with each new import.

    Beat

  • Random alphanumeric string

    Hello
    I need a function that generates a random alphanumeric string I want to use as a primary key value. It must therefore be unique also.
    Something similar to sys_guid in oracle, however I need length of chain attached to 6. sys_guid is not useful because it generates the long chain of 32 characters.

    Can anyone help please?

    Thanks in advance!
    RK

    You can find many examples by doing a search on this forum:
    Alphanumeric sequence numbers generator

  • LabVIEW and TestStand licenses

    Hello everyone, I did a lot of reading through the info OR on the case, but thought someone here could explain a little more clearly. Basically, I would like to know what is the licensing for Lv and TS applications, if I understand correctly, I will require an individual license for deployment on each machine that I want to run an application of TS, regardless of whether or not I have the software but launch an executable instead.

    In regards to LabVIEW, is the way to understand it, it seems to me that if a machine without LV who has LV runtime can run my executable, it does not require a special license? Can anyone shine some light on the matter?

    All this comes from the fact that my current job could ask implement TestStand and LabVIEW, as our current sequencer is simply too basic and rudimentary to the applications that we expect. It's a place big enough then, what would the licensing conditions? Runtime engine just for what works and a deployment of TS for stations that run it?

    ATTENTION: OR licenses are business of OR to keep up with your Rep OR!

    But in a word (as I navigate these waters for a living)

    • The LV runtime is all that is required to run that a LabVIEW built applications or LabVIEW modules called by TestStand in most cases.  The RTE LV is provided with an end-user license agreement, but the license is free.  OK OK... some LsbVIEW SDK may require additional deployment licenses.  I think that the Vision is one of those rare "needs a key deployment that is not free" toolboxes.  I've never deployed an executable LV requiring a deployment Toolkit cost-once again, check with your representative.
    • TestStand deployment licenses cost by target computer.  There are several options to the less expensive, the deployment of Base, more flexible options as a deployment "Debug" to risk mitigation, workflow of your compay, number of test stations and familliarity with deployment options, maturity of the Test system is expected to help guide the process of voluntary decision.

    Since it is a new path for your company, consult with an Alliance partner with experience in assessing your needs, regulatory environment, level of skills and practices.  (And no, TestStand deployment methods assessment is not a base of 8-Ball consulting so compentancy think not that I am marketing here)  You ask OR Rep and look the Alliance Partner Locator

  • When I try to boot from a bootable usb key, his shows bootmgr missing error.

    Bootmgr mising when you use a bootable usb key.

    I have windows 7 nvidia 2010 on my desk. I have a new laptop with a free version of linux. my laptop do not have a CD or dvd drive to start. When I'm trying to boot from a USB bootable, his error showing that bootmgr missing. Press ctrl + alt + delete to restart. I tried sp3 and xp sp2. having the same problem with both. Kindly help.

    Hello

    1. you are trying to install Windows XP by using the bootable USB key?

    Check if the sequence of the BIOS (Basic Input Output System) is set to boot to the operating system from the USB key.

    For more information get in touch with the manufacturer of the system.

    Note:

    BIOS change / semiconductor (CMOS) to complementary metal oxide settings can cause serious problems that may prevent your computer from starting properly. Microsoft cannot guarantee that problems resulting from the configuration of the BIOS/CMOS settings can be solved. Changes to settings are at your own risk.

  • My computer boots to the a: drive

    Original title: Operating system

    Hello, hope someone here can help, because I can't afford to hire the geek squad. I'm having all kinds of issues with my windows Vista professional. It seems that my computer is booting in drive a. This is my first problem.

    I'm not all removable working devices except when my computer starts up and once it is started in the light of my removable device turns off. I tried to install a new printer for nearly two weeks. My computer seems to recognize any device that I connect on port usb, but I can't hear a sound, and I never see the icon. The other crazy thing is that (with any removable device) when I go into my computer I have A player that I've ever had.

    The other problem is that I get the message that my devices need drivers and then recognize them and I installed them, but the devices still do not work.

    I was told that I might be accidentally deleted my operating system and because vista does not have a recovery disk, I don't know what to do. I did the restore and system defragmented more times that I care to say and my PC still not working right.

    Please I really could you some expertise. You can email me directly if you have a resolution. Thanks in advance.

    Hello

    ·        What is you get the exact error message?

    ·        Are you able to boot to the desktop normally now?

    You may need to check the boot sequence in the BIOS (Basic Input/output System). Enter the BIOS and change the boot sequence for the drive where the operating system is installed and check if that helps.

    http://Windows.Microsoft.com/en-us/Windows-Vista/BIOS-frequently-asked-questions

     

    Warning: Change (CMOS) BIOS/complementary metal oxide semiconductor settings can cause serious problems that may prevent your computer from starting properly. Microsoft cannot guarantee that problems resulting from the configuration of the BIOS/CMOS settings can be solved. Changes to settings are at your own risk.

    Hope this information is useful.

    Amrita M

    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • problems of corrupted recovery regsutry for Windows XP on the system restore

    Hello. Had a spyware (Trojan) killed by the virus cleaner, but on reboot, it gave me a famous lsass.exe error on an application that could not be deleted. At and read http://support.microsoft.com/kb/307545 but when tried to start the recovery from the Windows XP CD, the "copy c:\windows\repair\system c:\windows\system32\config\system" command did not work. Eventually managed to load the system from the CD, but then couldn't get part 2 (after the reboot safe mode) that the administrator password has been amended. I ran NT Password and registry Bootdisk from USB to remove the password of administrator but when tried to get back to the recovery console from the CD-ROM Windows XP, the computer turns off just before I have the option "R"-to start the recovery console. "" When I do not use the CD and try to turn on in a safe mode, it gives the BSOD. How do to so corrupted registry I can't system restore and recovery console?

    Any help is appreciated. I ran a diagnostic system and test at startup has past but on test drive, I get to 10% only global, and then it seems to take an indefinite period.

    How to make a manual SYSTEM RESTORE in XP, this should fix the missing or damaged configuration file.

    .
    A. connect your hard disk not bootable on another computer, as a secondary drive or use a usb adapter or pregnant, if you can see your data on the disk, save it now, and then follow the rest of these instructions.

    B. open the Windows Explorer. Click on tools | Folder options | View. Check the "show files and folders. Apply the change.

    NOTE

    D: do not represent the hard drive you connected to your PC, it can be E: or F: or G:, everything depends on how much other disks (including cd/dvd) so you have in your host PC, replace the drive letter to be appropriate in the instructions below.

    C. the D:\System Volume Information folder access. You will see a folder named something like _restore {...} points represent an alphanumeric sequence.
    In this folder, you will see folders named RP0... Nnpr. find the one with the largest number.
    What are your system restore points. In the higher-numbered folder, you will see a folder named snapshot. In this folder is the register of these files you need to recover your system:

    _REGISTRY_USER_.default

    _REGISTRY_MACHINE_SECURITY

    _REGISTRY_MACHINE_SOFTWARE

    _REGISTRY_MACHINE_SYSTEM

    _REGISTRY_MACHINE_SAM

    D. create a subdirectory; That is to say, D:\Windows\TMP. Copy these files in the TMP subdirectory. Rename them to:

    by default

    Security

    software

    System

    Sam

    Note of course losing the period (.) in the file named _registry_user_.default

    E. remove the files in the subdirectory D:\windows\system32\config of the same short name.

    F. copy of D:\windows\tmp in the D:\windows\system32\config files. subdirectory.

    G.Put your disk back into its original system. Your system should boot normally. If you get the error even repeat the procedure and choose another folder (Nnpr) (next higher number).

    You can repeat this procedure by choosing a smaller number Nnpr until you get the start again.
    If you are refused access to all files, you will need to take the first of 'Ownership' of the files. http://support.Microsoft.com/kb/308421

    If this procedure does not work, you need to repair or reinstall Windows.

  • Automatic to produce Digital Alpha

    Hi all

    Could you explain how we can generate alphanumeric id automatically as sequence, sys_guid (). In fact, our table to generate reference not as below

    A0001,A0002,A0003 A9999 then

    B0001,

    B0002

    B0003... B9999 then

    C0001 until C9999

    Thank you and best regards,

    JAI

    Take a look at:

    How to generate the alphanumeric sequence under oracle

    SK

  • auto-increment by alpha order

    Hi all

    I want to auto increment based on the groups recordings.

    I have data like below

    ----------------------------------------------------

    Area ID Extender

    --------------------------------------------------

    BA1 100

    BA1 120

    BA1 130

    GB1 190

    TC1 178

    TC1 193

    DX1 103

    I would like to have exit auto increment by as

    ----------------------------------------------------

    Area ID Extender

    --------------------------------------------------

    BA1 100A

    BA1 120A

    BA1 130A

    GB1 190 B

    TC1 178 C

    TC1 193 C

    103 D DX01

    ... and after Z, it should be AA, AB, AC, AD sequence

    could someone pls know that increments the sequence automatically.

    Rgds

    Saaz

    This question was asked several times, see, for example:

    https://community.Oracle.com/search.jspa?q=alphanumeric+sequence&place=%2Fplaces%2F1265&depth=all&customTheme=OTN

  • the dashboard by renaming

    I'm renaming my files using the custom text sequence, custom # {0001} but the dashboard between the needs of two fields to be an underscore and not a dashboard. How can I do that.

    This is because I CHANGED EVERYTHING in the Editor dialog box in the box under SAMPLE by selecting using the drop down menus.

    Delete everything in the box under sample

    INSERT a custom text

    type underscore

    INSERT the sequence # (0001)

    Save in a new preset if you want.

  • question about renaming a set of photographs

    I want to rename a series of photographs to the custom help name-sequence, where the first number is 0001.  Although I enter as the bib number in the dialog box when I click OK, the images are renamed custom name - 1, rather than name personalized-0001.  Is there a way to force the program to use the four digital architecture?  I work in Lightroom 3 Mac OS 10.5.8.

    In the Model Editor, you have the option to choose between {sequence # (1)} and {sequence # (0001)} and everything. You must choose the latter.

    I don't know if the templates have one of the suits you. You may need to modify one of the existing templates or create a new.

  • kind of basic question on navigation of the sequence

    then I got a new job and worked with Avid Newscutter there. not much fan of passionate, but there is a feature that has been sloppy. When you hold down the control and right mouse and browse your sequence, difficult playhead stops at each edit point. is it possible to imitate this behavior in first? I know that I can just press up and down to scroll edit them points, but sometimes it is not practical, according to what I do.  Thank you.

    Up and down is the only way I know how.

  • Four basic questions about sequences

    DB version: 11

    Question * 1 * and * 2 *:
    To determine the current value of a suite I try
     
     SQL> SELECT  SEQ_SHP_HDR.CURRVAL FROM DUAL;
     SELECT  SEQ_SHP_HDR.CURRVAL FROM DUAL
             *
     ERROR at line 1:
     ORA-08002: sequence SEQ_SHP_HDR.CURRVAL is not yet defined in this
     session
    I know that if I use
    SELECT  SEQ_SHP_HDR.NEXTVAL FROM DUAL;
    I can get the sequence CURRVAL. But that increments the sequence.


    So I tried to look at user_sequences.last_number. But user_sequences.last_number showed 552 when the real currval was 545.

    Why I am getting the error above (SEQ_SHP_HDR. CURRVAL is not yet defined in this session) and how can they accurately determine
    the currval in a sequence without increment using NEXTVAL?



    Question * 3 *.
    To increment a sequence,
    alter sequence <sequencename> increment by n ;
    Right?

    Use you guys
    SELECT  <sequencename>.NEXTVAL FROM DUAL;
    to increment the SEQUENCE?


    Question * 4 *.

    I was trying to increment a sequence. When the ALTER statement, the sequence did not get incremented. I had to call a NEXTVAL to get actually it reflected. Why is this happening?
    SQL> select * from v$version where rownum=1;
    
    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11g Release 11.1.0.7.0 - 64bit Production
    
    SQL> CREATE SEQUENCE myseq
      2    START WITH 1
      3    NOMAXVALUE;
    
    Sequence created.
    
    SQL> select myseq.nextval from dual;
    
       NEXTVAL
    ----------
             1
    SQL> alter sequence myseq increment by 7;
    
    Sequence altered.
    
    SQL> select myseq.currval from dual;
    
       CURRVAL
    ----------
             1
    SQL> select myseq.nextval from dual;
    
       NEXTVAL
    ----------
             8
    
    SQL> select myseq.currval from dual;
    
       CURRVAL
    ----------
             8
             

    Steve_74 wrote:
    DB version: 11

    Question * 1 * and * 2 *:
    To determine the current value of a suite I try

    
    SQL> SELECT  SEQ_SHP_HDR.CURRVAL FROM DUAL;
    SELECT  SEQ_SHP_HDR.CURRVAL FROM DUAL
    *
    ERROR at line 1:
    ORA-08002: sequence SEQ_SHP_HDR.CURRVAL is not yet defined in this
    session
    

    I know that if I use

    SELECT  SEQ_SHP_HDR.NEXTVAL FROM DUAL;
    

    I can get the sequence CURRVAL. But that increments the sequence.

    So I tried to look at user_sequences.last_number. But user_sequences.last_number showed 552 when the real currval was 545.

    Why I am getting the error above (SEQ_SHP_HDR. CURRVAL is not yet defined in this session) and how can they accurately determine
    the currval in a sequence without increment using NEXTVAL?

    You can't the CURRVAL unless you run the NEXTVAL alteast once in your session. And you cannot use the user_sequences.last_number if the CACHE is enabled.

    Question * 3 *.
    To increment a sequence,

    alter sequence  increment by n ;
    

    Right?

    EVIL! You have actually changed the structure of your sequence. With ALTER comand, you actually set the increment value. Here, "n" sets the size of the increment. If defined as 1 it increments by 1. If as 2 will increment by 2.

    Use you guys

    SELECT  .NEXTVAL FROM DUAL;
    

    to increment the SEQUENCE?

    YES, it's the good way to increment a sequence. Use NEXTVAL to increment a sequence.

    Question * 4 *.

    I was trying to increment a sequence. When the ALTER statement, the sequence did not get incremented. I had to call a NEXTVAL to get actually it reflected. Why is this happening?

    SQL> select * from v$version where rownum=1;
    
    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11g Release 11.1.0.7.0 - 64bit Production
    
    SQL> CREATE SEQUENCE myseq
    2    START WITH 1
    3    NOMAXVALUE;
    
    Sequence created.
    
    SQL> select myseq.nextval from dual;
    
    NEXTVAL
    ----------
    1
    SQL> alter sequence myseq increment by 7;
    
    Sequence altered.
    
    SQL> select myseq.currval from dual;
    
    CURRVAL
    ----------
    1
    SQL> select myseq.nextval from dual;
    
    NEXTVAL
    ----------
    8
    
    SQL> select myseq.currval from dual;
    
    CURRVAL
    ----------
    8
    

    Response to question 3, it responds as well!

Maybe you are looking for