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>

Tags: Database

Similar Questions

  • Generate select 2 in the same statement consecutive sequence numbers

    Hello
    Could someone please tell me how to generate 2 consecutive sequence numbers in the same select statement.

    See you soon
    CREATE SEQUENCE my_seq
    INCREMENT BY 2
    /
    
      select nxt_value
            , nxt_value + 1
     from ( select my_seq.nextval nxt_value from dual )
    /
    

    Anton

  • The use of sequence and generate the number in a table that has data

    Hello

    There is a custom table that has a column Rowid (NULL).
    This table already has 10 k with rowid as null lines, now the user asks me to enter a unique number for the Rowid.
    I created a sequence, but don't know how to use this sequence and generate numbers for the Rowid.

    Could you suggest.

    Thank you.

    "rowid" is an oracle reserved word and should be avoided. Perhaps "Rowid" between quotes or something.

    Here's how to "fill" a column by a sequence:

    SQL> create table t (id number, value varchar2(100));
    
    Table created.
    
    SQL> insert into t (value) select object_name from all_objects where rownum <= 10000;
    
    10000 rows created.
    
    SQL> create sequence idgen_sequence;
    
    Sequence created.
    
    SQL> update t set id = idgen_sequence.nextval;
    
    10000 rows updated.
    

    Given that the sequence was used all the 'id's will be unique.

  • sequence numbers

    Hello

    I need to generate sequence numbers for each order based on the time of the edict
    table:order_edits
    
    has 2 columns
    id number (10)
    edit_time (date)
    date of the sample

    ID EDIT TIME
    9009-1/31 / 2010 13:10
    9009-1/31 / 2010 14:10

    9002 1/27 / 2010 09:00

    9007 1/15 / 2010 11:15
    9007 1/17 / 2010 09:00
    i am looking for sequence numbers for each orderid based on edit time
    Order_edit of TIME CHANGE ID
    9009-1/31 / 2010 13:10 1
    9009-1/31 / 2010 14:10 2

    9002 1/27 / 2010 09:00 1

    9007 1/15 / 2010 11:15 1
    9007 1/17 / 2010 09:00 2


    any help is appreciated                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        

    Hello

    The ROW_NUMBER analytic function has been designed for this:

    SELECT       id, edit_time
    ,       ROW_NUMBER () OVER ( PARTITION BY  id
                                ORDER BY          edit_time
                        )    AS order_edit
    FROM      order_edits
    ORDER BY  id, edit_time          -- Optional
    ;
    

    If (id, edit_time) is not unique, each row will always get a separate number.

    The ORDER BY clause from the query (if it exists) is independent of the ORDER byclause Analytics . The two may be identical, they may be similar (see above), or they may have nothing at all in common.

  • Create sequence numbers when importing data

    Hi, I am looking to insert data into a table that already has data in.

    I have a 2-sequence numbers that I need to include in the statement. The first (RSC_RDSS) must be pulled from another field of SRS_RDS table RDS_SEQ2 where the RDS_SCJC is the same on both records. The second RSC_SEQN must increment by 1 for all existing records.

    I currently have a basic script:

    INSERT INTO SRS_RSC (RSC_SCJC, RSC_FTIT, RSC_RDSS, RSC_SEQN, RSC_BEGD, RSC_ENDD, RSC_NOTE)
    VALUES (' 0848633'/ 2 ', ' ELC100/10: University grammar ', '1', '50', to_date (April 4, 11 '), to_date (April 4, 11 '), 'Test topic' ");

    How can I get the RSC_RDSS to another table and how can I get the RSC_RDSS to look at what is in the picture in terms of number of records for this person (RSC_SCJC) and increment by one?

    Thanks in advance.

    Jonathan

    Hello

    I'm not sure I understand all your requirements, but here's an example of what you can do:

    INSERT INTO SRS_RSC (RSC_SCJC, RSC_FTIT, RSC_RDSS, RSC_SEQN, RSC_BEGD, RSC_ENDD, RSC_NOTE)
    select
        '0848633/2' as RSC_SCJC,
        'ELC100/10: Academic Grammar' as RSC_FTIT,
        (select RDS_SEQ2 from SRS_RDS where RSC_SCJC ='0848633/2') as RSC_RDSS ,
        (select max(RSC_SEQN)+1 as RSC_SEQN from SRS_RSC) as RSC_SEQN,
        to_date('04-Apr-11') RSC_BEGD,
        to_date('04-Apr-11') RSC_ENDD,
        'Test heading' RSC_NOTE
    from dual;
    

    Please note that each of the 2 subqueries must return only one row.

    Hope it helps.

    Kind regards
    Sylvie

  • 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.

  • Generator of sequence numbers for any number of PDF forms

    Hello

    With the help of this forum, I now have a simple Workbench process that acts as a Web service to generate a sequence number.

    When it is called by a PDF form it reads a value in a database, increment the value and then reads the db to return the value incremented to the form.

    It works fine, but now I need something else: I have about 60 forms and each will have its own sequence.

    The way I see what I have to do is:

    -include a new column in the db table to store the IDs forms (I already did).

    -modify the SQL statements to include the number of Ref form as a parameter of a WHERE clause (I already did).

    and...

    -Send the Ref form number from the PDF file during the call to the web service. = > I have not yet figured out how do.

    -receive this Ref number in the workbench to use as a parameter in the WHERE clause.

    Please could someone help me out here?   Or point to a few examples online that I could use as a guide?

    Will I receive the news of the PDF in the form of XML file and extract the info from its structure?

    Thanks much for the advice.

    Marcos

    Hello

    Any variables created within a process are accessible by all of the finding.

    You don't need to associate the value through the extra activity.

    for example you can directly use the value of the variable in the SQL activity to increment & get the next number in the sequence.

    Note that you must not even two activities SQL to do. A single SQL activity can execute multiple SQL queries.

    Hope that helps.

    Nith

  • Sequence ID generator

    Hello world

    I have Forms 6i and a colleague you have send me the following code to generate IDs and I insert this code in my program unit

    like a function body, but when I compile the program I get the following error:

    BDP-PPU017 the source of program unit must define a body of subprogramme or packaging.

    FUNCTION to CREATE or REPLACE generated_id (p_table VARCHAR2) NUMBER of RETURN IS

    l_generated_id NUMBER;

    l_table_name VARCHAR2 (30): = SUPERIOR (p_table);

    BEGIN

    BEGIN

    ID SELECT INTO l_generated_id

    FROM my_table

    WHERE NOMBRE_TABLE = l_table_name

    UPDATE; -it blocks the current line

    l_generated_id: = l_generated_id + 1;

    UPDATE my_table

    SET id = l_generated_id

    WHERE NOMBRE_TABLA = l_table_name;

    EXCEPTION

    WHEN NO_DATA_FOUND THEN

    l_generated_id: = 1;

    INSERT INTO my_table (NOMBRE_TABLA, id)

    VALUES (l_table_name, l_generated_id);

    END;

    RETURN l_generated_id;

    END;

    Can someone please help me solve this problem?

    BDP-PPU017 the source of program unit must define a body of subprogramme or packaging.

    Moreover, the reason why you get this error is because you cannot use the CREATE or REPLACE in a program unit Oracle Forms syntax.  It's only the syntax of database.  If you want to use this method, set the function in the database if you make several trips to the forms database.

    This solution has a specific purpose - to make a gapless sequence, if you need (Oracle sequences will never generate a free sequence space of numbers).

    It is very good for a value which must be gapless, but I would not use it as the primary key for a table ID.  In addition, how well this code takes in a multi-user environment?  Since there is no COMMIT in the service, I assume that the validation will come from the routine by calling the Generate_ID function.  That being the case, it is possible that another session might call this function and get the same ID as a session that did not err again and validate before the previous session, making the ID generated by this session a duplicate.  (This makes sense?).

    Just my thoughts on this...

    Craig...

  • gaps in the sequence numbers

    Hello

    Using 11.2.0.3 with the code below to try to generate sequnec number when no other number found.

    Get numbers seq greate gaps as 1 in them and not starting not not to the specified number

    What I am doing wrong?
    execute immediate('drop sequence NON_SAP_BUSINESS_PARTNER_SEQ');
    -- Create sequence 
    execute immediate('create sequence NON_SAP_BUSINESS_PARTNER_SEQ
    minvalue 600225
    maxvalue 699999
    start with 600225
    increment by 1
    nocache');
    
    Thanks
    
    
    CASE WHEN x.ccr_bus_partner_id IS not null
             then x.ccr_bus_partner_id
          else
              nvl(initial_load.RETURN_bp_number(cd_urn,cd_hub_num,cd_legacy_box_num),NON_SAP_BUSINESS_PARTNER_SEQ.nextval)
              
    end case   

    user5716448 wrote:
    Hello

    Using 11.2.0.3 with the code below to try to generate sequnec number when no other number found.

    Get numbers seq greate gaps as 1 in them and not starting not not to the specified number

    What I am doing wrong?

    execute immediate('drop sequence NON_SAP_BUSINESS_PARTNER_SEQ');
    -- Create sequence
    execute immediate('create sequence NON_SAP_BUSINESS_PARTNER_SEQ
    minvalue 600225
    maxvalue 699999
    start with 600225
    increment by 1
    nocache');
    
    Thanks
    
    CASE WHEN x.ccr_bus_partner_id IS not null
    then x.ccr_bus_partner_id
    else
    nvl(initial_load.RETURN_bp_number(cd_urn,cd_hub_num,cd_legacy_box_num),NON_SAP_BUSINESS_PARTNER_SEQ.nextval)
    
    end case   
    

    Depending on your State and the code used, the nextval will be determined for each row retrieved in a query (i.e. the other condition of a case may be partially or fully assessed causing the nextval must be retrieved even if it is not used).

    You should not rely on objects of the sequence of sequences "gapless". This is not what they are designed for and gap free sequences are not guaranteed with them.

  • How to create a sequence that generates in the form of intellectual property?

    Hello

    I want to create a sequence that can generate an IP numbers. as

    224.0.0.1
    224.0.0.2
    .
    .
    .
    224.255.255.255

    Is this possible?


    Thank you very much

    KinsaKaUy? wrote:

    Then, just the format of address IP (exercise left to you)

    Hint please :)

    Enter the socket interface ntoa - simple enough to reproduce in the SQL and PL/SQL.

    PS. Look in the section "+ dotted IP number +"-it should run to the top of implementation details.

  • BlackBerry smartphone how to react to alphanumeric phone numbers

    In this era of smartphones always presents us with phone numbers alphanumeric (for example 'support dial 800-5helpme').  Mnemonics are not much help, if you do not have a keyboard with the alphabet above or you have not memorized it. There at - it an application or option that allows aid - for example, an application that shows the cushion on the screen?)  Thank you. Rob

    To compose letters, just hold the ALT key before clicking on each letter. Thus, for example, to dial the 800-COMCAST, you would all dial 800 - ALT C, ALT O, M ALT, etc. until you get to the end.

  • Sequence numbers and image

    I've recently upgraded to 6.5.1 and I only downloaded a map/game of images so far. All image numbers are wrong. I only took about 1500 images on my new camera, but since the download I have numbers as high as 5500 and the images are in the wrong order too. Is it possible to retrieve the correct numbers according to the map? And if so, how? Which would also sort the incorrect sequence? If not, I would delete the catalog, but I would like to remove the disc too... is that necessary and or possible?

    First, you might want to check to be sure somehow that your settings in Lightroom import dialog box did not include some renaming of file names. If this happens accidentally, I would disable this option, then delete the photos from Lightroom and from the hard drive and import them again with no renaming of files.

    To change the inside Lightroom sort order, use the menu command view-> sort-> Capture time

    Finally, a change of out-of-the-box, your solution of mentality to the whole problem: shrug and do nothing. What difference does make in the long run, this number is on the file name of the picture? Everything what you going to do with these photos, you can still do despite the number change. This is by far the easiest solution.

  • Sequence creates random numbers instead of sequence numbers

    Hello

    I created a sequence on a column in the table and then I created a trigger before insert on this table. Here's the script:

    CREATE SEQUENCES SEQ_COL1
    START WITH 1
    MAXVALUE 9999999999999999999999999999
    MINVALUE 1
    NOCYCLE
    NOCACHE
    ALL;

    CREATE OR REPLACE TRIGGER trig_table1
    before inserting
    Table 1 for each line
    Start

    If: new.col1 is null then
    Select seq_col1.nextval in: double new.col1;
    end if;
    end;

    The problem I have is, the number generated for the col1 is random as after 1, it goes to 230 then to 340 etc... instead of being sequential.

    Please let me know if I'm missing something.

    Hello

    Use the ORDER parameter in your create sequence - statement.

    Heike cordially

  • Get only the alphanumeric column numbers

    Hi all

    How can I get to the numbers in the alphanumeric column?
    I use the following question for this.


    with tab as)
    Select 25 - Abc' key1 of union double all the
    Select 233 - xyz' key1 of union double all the
    Select 'x23A' key1 in union double all the
    Select 91 w-2-dd-2' double key1
    )
    tab, select regexp_substr(key1,'[[:digit:]]+')


    But here the last row (91-w-2-dd-2) returns only two first digits (91). But I need 9122.
    My version of oracle's 10g release 2.

    Thank you
    Sujnan

    This can do

    Processing ...
    with tab as (
    select '25-Abc' key1 from dual union all
    select '233-xyz' key1 from dual union all
    select 'x23A' key1 from dual union all
    select '91-w-2-dd-2' key1 from dual
    )
    select regexp_replace(key1,'[^0-9]+','') from tab
    Query finished, retrieving results...
                            REGEXP_REPLACE(KEY1,'[^0-9]+','')
    --------------------------------------------------------------------------------
    25
    233
    23
    9122                                                                             
    
    4 row(s) retrieved
    

    Alessandro Bye

  • Problem of eve - of sequence numbers

    Hello world! I'm on 10.2.0.3.

    My physical Eve stopped applying newspapers because all of a sudden, the newspapers are out of sequence. See the errors below - after seq 7975 & 7976 seq # 7974 showed once again:

    Online Redo Log recovery: thread 1 mem group 200 Seq 7974 reading 0
    Mem # 0: /db/data3/FSPRD/stby_redo02.log
    MEM # 1: /db/data4/FSPRD/stby_redo02_02.log
    Game 18 dec 16:14:58 2008
    RFS [23]: Eve successfully opened log 100: ' / db/data1/FSPRD/stby_redo01.log'
    Game 18 dec 16:15:01 2008
    RFS [25]: open successfully the journal watch 300: ' / db/data5/FSPRD/stby_redo03.log'
    Game 18 dec 16:15:01 2008
    Primary database is in MAXIMUM PERFORMANCE mode
    RFS [37]: open successfully the journal ensures 400: ' / db/data7/FSPRD/stby_redo04.log'
    Game 18 dec 16:15:02 2008
    RFS [24]: open successfully the journal watch 200: ' / db/data3/FSPRD/stby_redo02.log'
    Game 18 dec 16:15:03 2008
    Media, recovery waiting for thread 1 sequence 7975 (in transit)
    Game 18 dec 16:15:03 2008
    Online Redo Log recovery: thread 1 mem group 100 Seq 7975 reading 0
    Mem # 0: /db/data1/FSPRD/stby_redo01.log
    MEM # 1: /db/data2/FSPRD/stby_redo01_02.log
    Media, recovery waiting for thread 1 sequence 7976 (in transit)
    Game 18 dec 16:15:07 2008
    Online Redo Log recovery: thread 1 mem group 200 Seq 7974 reading 0
    Mem # 0: /db/data3/FSPRD/stby_redo02.log
    MEM # 1: /db/data4/FSPRD/stby_redo02_02.log
    MRP0: Background Media Recovery terminated with error 355
    Game 18 dec 16:15:12 2008
    Errors in the /db/dbdump/FSPRD/bdump/fsprd_mrp0_11351.trc file:
    ORA-00355: change the numbers in the wrong order
    ORA-00353: journal corruption near Block 2 change 4994299896 time 18/12/2008 16:14:57
    ORA-00312: wire of 1 200 online newspaper: ' / db/data4/FSPRD/stby_redo02_02.log'
    ORA-00312: wire of 1 200 online newspaper: ' / db/data3/FSPRD/stby_redo02.log'
    Managed Standby recovery not using real time applies
    Game 18 dec 16:15:12 2008
    Primary database is in MAXIMUM PERFORMANCE mode
    RFS [37]: Eve successfully opened log 100: ' / db/data1/FSPRD/stby_redo01.log'
    Game 18 dec 16:15:13 2008
    Recovery interrupted!
    Game 18 dec 16:15:13 2008
    Errors in the /db/dbdump/FSPRD/bdump/fsprd_mrp0_11351.trc file:
    ORA-00355: change the numbers in the wrong order
    ORA-00353: journal corruption near Block 2 change 4994299896 time 18/12/2008 16:14:57
    ORA-00312: wire of 1 200 online newspaper: ' / db/data4/FSPRD/stby_redo02_02.log'
    ORA-00312: wire of 1 200 online newspaper: ' / db/data3/FSPRD/stby_redo02.log'
    Game 18 dec 16:15:13 2008
    MRP0: Stopping the process background Media Recovery (FSPRD)
    Game 18 dec 16:15:19 2008

    Of course I rebooted managed recovery and everything went well from this time - but I could not find the cause of this problem.

    Anyone has any ideas - or have experienced this before?

    TIA.

    I'm afraid you tap bug 6039415 ORA-355 can occur during the real time applies, the good news: there is a patch.

    HTH

    Enrique

Maybe you are looking for

  • Satellite L100 170: can I put the graphics card?

    Hi everyone :) could someone tell me if I can upgrade the graphics card in the Satellite L100-170, for the moment, it has an ATI Radeon® Xpress 200 M, if I can what is the best card to upgrade this machine to and where I could get one from?Thank you

  • While the loop does not stop within a structure of business

    Hi all I have a business structure that works an engine to a certain PWM when my metal detector does not give an amount greater than the threshold that is ' false '. The motor is controlled by a PI controller so a while loop is used inside the false

  • Internet Explore cannot download.

    Internet Explore cannot download, the connection with the server was reset or the time is out.  With this I can never do no downloading, installation or upgrade. Help, please.

  • Password BIOS reset for HP Pavilion DV4 - 1283cl

    I am working on a friends computer who forgot his password for the BIOS... it's a HP Pavilion dv4 - 1283cl and generates a "system to disable the key: 620705680. Any suggestions on how to reset?

  • HP5550 colour laser - Win 7 PC using a driver universal B &amp; W print. No color.

    I already used HP5550 color HP laserjet driver CD, to load the drivers on all our computers. With the move to Windows 7, the only choice for a print driver seems to be the pilot universal. However, the universal driver displays only B & W for us. No