Creation of sequences in oracle

I know how to create the sequence. But ever-increasing sequence is created. If I want to create a top-down sequence and then how to build?
INCREMENT BY -1

Max
http://oracleitalia.WordPress.com

Tags: Database

Similar Questions

  • How to create a generic method to programmatically access the DB sequence in oracle adf

    Hello

    I am trying to create a generic method to access a programmaticall DB Sequence in oracle adf. My version of JDeveloper is 11.1.2.4.

    I created a method getSequenceNumber (String seq) and saved in my application module. Also added to the links of my page.

    I followed the instructions below link for this.

    ADF Code corner: Oracle OTN JDeveloper harvest xx / 2010

    Note: The problem with this approach is that I have to create separate methods to access the different sequence numbers.

    In my managed bean, I wrote the code below to get the method name.

    OperationBinding getNextSequence = ADFUtils.findOperation ("getSequenceNumber");

    How can I pass my sequence DB name to this method?

    Thank you

    Hello

    getNextSequence.getParameterMap.put ("seq", "yuorseqname");

    getNextSequence.execute ();

  • Creation of storage in Oracle 11 g

    Hi guys,.

    I need to create storage for our development database.
    Currently I am the creation of storage as below

    TABLESPACE CREATION tools
    DATAFILE ' / data/oracle/oradata/tpol/tools01.dbf' SIZE 10 M REUSE AUTOEXTEND ON NEXT 1 M
    MAXSIZE UNLIMITED MANAGEMENT SEGMENT SPACE MANAGEMENT AUTO LOCAL SCOPE;

    CREATE TABLESPACE cash_box_data_tbs
    DATAFILE ' / data/oracle/oradata/tpol/cash_box_data01.dbf' SIZE 10 M REUSE AUTOEXTEND on NEXT 10 M
    MAXSIZE UNLIMITED MANAGEMENT SEGMENT SPACE MANAGEMENT AUTO LOCAL SCOPE;

    CREATE TABLESPACE cash_box_ndx_tbs
    DATAFILE ' / data/oracle/oradata/tpol/cash_box_ndx01.dbf' SIZE 10 M REUSE AUTOEXTEND on NEXT 10 M
    MAXSIZE UNLIMITED MANAGEMENT SEGMENT SPACE MANAGEMENT AUTO LOCAL SCOPE;

    CREATE TABLESPACE cash_drawer_data_tbs
    DATAFILE ' / data/oracle/oradata/tpol/cash_drawer_data01.dbf' SIZE 10 M REUSE AUTOEXTEND on NEXT 10 M
    MAXSIZE UNLIMITED MANAGEMENT SEGMENT SPACE MANAGEMENT AUTO LOCAL SCOPE;

    CREATE TABLESPACE cash_drawer_ndx_tbs
    DATAFILE ' / data/oracle/oradata/tpol/cash_drawer_ndx01.dbf' SIZE 10 M REUSE AUTOEXTEND on NEXT 10 M
    MAXSIZE UNLIMITED MANAGEMENT SEGMENT SPACE MANAGEMENT AUTO LOCAL SCOPE;


    I was wondering is it possible to set the path to/data/oracle/oradata/tpol/and if I create the table automatically space the data file could be created in the above path.


    Please give me some suggestions. I am using Oracle 11g

    Use the OMF and DB_CREATE_FILE_DEST

    DB_CREATE_FILE_DEST

    Sets the location of the default directory where Oracle create datafiles or tempfiles when no specification file is given in the create operation.

  • Creating a sequence in oracle 11 g 2 issue

    Hello.. I use version 11.2 oracle. How can I create my sequence value starts from 1.i do me now 2. Please help me...

    Hi, I'm posted this thread, but now I found that is the question

    in oracle 11.2 (11 GR 2), which is the new feature "deferred_segment_creation" = true I think that is the question.
    Now, I changed the default value FALSE the problem sloved. the number of this sequence starts 1

    http://www.dbsnaps.com/Oracle/Oracle-deferred-segment-creation/

    I hope this is useful

    Thanks for the reply

    knockaert

  • How to create a sequence in oracle forms6i

    Oracle forms 6i


    Hai All

    I work in a leave request entry, so I need to create a sequence to give a unique number for each entry

    Pls tell me the steps how to create and how to call the sequence of database


    Thanks in advance

    Srikkanth.m

    Hello
    Sequence, you can create in the database and you can use this sequence generation sequence number forms
    Creation, see link below...
    http://www.techonthenet.com/Oracle/sequences.php
    http://psoug.org/reference/sequences.html

    To generate numbers forms use like that...

    For each entry at the time of save you can use on PRE-INSERT of block level
    SELECT SEQUENCE_NAME.NEXTVAL
    INTO :FORM_FIELD_NAME
    FROM DUAL;
    

    -Clément

  • The creation of sequence error. Help, please

    I use following script to create the sequence but in error
    Error report:
    SQL error: ORA-01722: invalid number
    01722 00000 - "invalid number."


    CREATE SEQUENCES BL_BTN_MASTER_SEQ
    MINVALUE 1
    MAXVALUE 999999999999999999
    INCREMENT BY 1
    START WITH (SELECT MAX (BULLETIN_MASTER_ID) + 1
    OF BL_BTN_MASTER)
    NOCACHE;

    FYI... The bulletin_master_id column data type is NUMBER (22.0)
    Help, please.

    Published by: user11228834 on May 29, 2013 10:22

    Published by: user11228834 on May 29, 2013 10:23

    Published by: user11228834 on May 29, 2013 10:25

    Oracle doesn't like the ' (select max (bulletin_master_id) + 1 bl_btn_master)' statement incorporated in the CREATE SEQUENCE statement because if you look at the syntax it expects an acual number.» You can use run immediately to create the sequence in this way:

    {code}
    declare
    number of v_seq;
    v_statement varchar2 (200);
    Start
    SELECT max (bulletin_master_id) + 1
    in v_seq
    of bl_btn_master;

    v_statement: = 'CREATE the SEQUENCE BL_BTN_MASTER_SEQ |
    "MINVALUE 1' |
    "MAXVALUE 999999999999999999' |
    ' INCREMENT OF 1' |
    'START WITH ' | v_seq |
    "NOCACHE";

    execute immediate (v_statement);
    end;
    {code}

  • Issue when inserting into a table using sequence in Oracle 11 g Rel 2

    Hi all

    I am facing problem when I insert sequence values in my table.
    When inserting, my sequence does not begin with the beginning with the value.
    Example Script

    CREATE SEQUENCE xyz_seq
    START WITH 1
    INCREMENT BY 1
    NOMAXVALUE
    MINVALUE 1
    NOCYCLE
    NOCACHE
    ALL;

    create table abc (a number not null);

    insert into abc (xyz_seq.nextval) values;

    Select *.
    ABC;

    xyz_seq sequence of fall;

    drop table abc;

    Output

    Order of creation.
    Table created.
    1 line of creation.

    ONE
    ----------
    2
    1 selected line.
    Sequence has fallen.
    Deleted table.

    I can't understand why this is inserting value 2, when my sequence should start at 1.


    To overcome that road, I implemented a different logic.
    Example of

    CREATE SEQUENCE xyz_seq
    START WITH 1
    INCREMENT BY 1
    NOMAXVALUE
    MINVALUE 1
    NOCYCLE
    NOCACHE
    ALL;

    create table abc (a number not null);
    declare
    x number (1): = xyz_seq.nextval;
    Start


    insert into abc (x) values.
    end;
    Select *.
    ABC;

    xyz_seq sequence of fall;

    drop table abc;

    Output

    Order of creation.
    Table created.
    PL/SQL procedure successfully completed.

    ONE
    ----------
    1
    1 selected line.
    Sequence has fallen.
    Deleted table.

    However, my question remains why referring to the sequence.nextval in my insert does not return me the beginning with the value.

    Kind regards
    Rishi

    That's what says the doc ;

     If you attempt to insert a sequence value into a table that uses deferred segment creation, the first value that the sequence returns will be skipped.
    

    It ignores the value 1 and returns 2.

  • With regard to the creation of sequence and relaxation

    Hello!!
    I use oracle 10g and I have tried to create a sequence of a table called 'emp' I need to autoincrement column 'emp_id' which has a varchar2 data type. How do I?
    Help, please!

    1 sequence cannot be linked to any specific table. They generate only sequential numbers and like [url http://asktom.oracle.com/pls/asktom/f?p=100:11:0:NO:P11_QUESTION_ID:2985886242221] Tom says: there is a 100% guarantee that the values generated by the sequence will have some gaps.
    2 sequence cannot be auto incremented. You must use Sequence.Nextval (). Either use directly in your insert statement or write a trigger for this.
    3. If the emp_id column is supposed to contain sequence values (which are numbers), why are you define as VARCHAR2? Keep in a number only.

    Vivek L

  • creation of sequences on fly

    Dear Experts,

    This script works very well

    
    declare
           v_seq_name varchar2(30);
           v_var_name varchar2(10) := 'TEST';
            v_curr_value number := -1;
              v_dummy number;
              l_MaxVal  number :=6;
    begin
            v_seq_name := 'SEQ_' ||  v_var_name;
    
         dbms_output.put_line(' value of l_MaxVal : ');
         dbms_output.put_line(l_MaxVal );
    
    
    
    
       SELECT count(*)
      INTO v_dummy
      FROM user_sequences
      WHERE sequence_name = 'SEQ_TEST';
      dbms_output.put_line(v_dummy);
      IF v_dummy = 0 THEN
         --   DBMS_UTILITY.EXEC_DDL_STATEMENT('CREATE SEQUENCE SEQ_TEST');
          execute immediate 'CREATE SEQUENCE ' || v_seq_name ||
           ' MINVALUE 1 MAXVALUE 999999999999999999999999999 START WITH 1 increment by 1 cache 20';
      END IF;
    
    
      IF v_dummy = 1 THEN
         dbms_output.put_line('else');
           loop
             execute immediate 'select ' || v_seq_name || '.nextval from dual' into v_curr_value;
             dbms_output.put_line(v_curr_value);
             dbms_output.put_line('<');
             dbms_output.put_line(l_Maxval);
              exit when v_curr_value > l_Maxval;
             end loop;
      END IF;
     end;
    /
    
    

    It will not work

    DECLARE
       v_dummy NUMBER;
       l_MaxVal  pls_integer default 6;
       l_Currval pls_integer default - 1;
     BEGIN
    
    
       SELECT count(*)
       INTO v_dummy
       FROM user_sequences
       WHERE sequence_name = 'SEQ_TEST';
    
    
     if(v_dummy =0 ) THEN
         EXECUTE IMMEDIATE 'create sequence SEQ_TEST';
     ELSIf(v_dummy =1 ) THEN
    
    
          
       while l_Currval < l_Maxval
       Loop
       select SEQ_TEST.nextval into l_Currval FROM dual;
       END loop;
     END IF;
     END; 
    

    Can you please have your ideas, why the code above won't work.

    No, the answer is not to create clips dynamically.  It should not be a reason to do such a thing, if the database and the application is designed correctly.

    A sequence must be created once as part of the initial design of the database, has NOT created on the fly.  It goes same for tables and most of the other objects in the database.

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

  • Creation next sequence

    I need to insert a record into a table that is not a sequence object. The table contains types of user of the system.
    USER_TYPE DESC
    Name                           Null     Type                                                                                                                                                                                          
    ------------------------------ -------- ----------------
    USER_TYPE_ID                   NOT NULL NUMBER                                                                                                                                                                                        
    USER_TYPE                               VARCHAR2(100)                                                                                                                                                                                 
    USER_TYPE_PID                           NUMBER                                                                                                                                                                                        
    ABBR                                    VARCHAR2(15) 
    There are 100,000 records.
    An error appears when I try the following:
    CREATE SEQUENCES USER_TYPE_ID_SEQ
    INSERT INTO user_type (USER_TYPE_ID, USER_TYPE, USER_TYPE_PID, ABBR) VALUES (USER_TYPE_ID_SEQ.nextval, 'UNASSIGNED', NULL, NULL)
    Error report:
    SQL error: ORA-00001: unique constraint (DEV_FIRM_CCB. USER_TYPE_USER_TYPE_ID_PK) violated
    00001 00000 - "forced single (s.%s) violated."
    What the USER_TYPE_USER_TYPE_ID_PK about USER_TYPE_ID column.

    How to start the next sequence of the max value of USER_TYPE_ID (100,000).
    Something like this:
    CREATE THE USER_TYPE_ID_SEQ SEQUENCE WITH (SELECT INTEGER (MAX (USER_TYPE_ID) + 1) OF USER_TYPE)
    But it does not work. Any help is appreciated.

    Achtung wrote:

    Assuming that nobody is insert in user_type table while you run the code:

    declare
        v_stmt varchar2(1000);
    begin
        select  'create sequence user_type_id_seq start with ' || max(user_type_id)
          into  v_stmt
          from  user_type;
        execute immediate v_stmt;
    end;
    /
    

    SY.
    PS The name of the Table USER_TYPE is a bad choice - too close to display name of data dictionary USER_TYPES.

  • Creation of domain to 0% - Oracle 11g - Windows Server 2008 64 bit PFRD

    1.i want to install and configure Oracle FMW version 11.1.1.2.0 in Windows server 2008 64 bit.

    2.i have followed the steps too as described here in these links two forum:
    1.http://CN.forums.Oracle.com/forums/thread.jspa?threadID=2245015
    2.creation area at 0% - Oracle PFRD 11 g - Windows Server 2008 64-bit

    3.I give my installtion No...

    I installed the JDK: 1.7.0.
    I have correctly installed web logic version wls1035_generic.jar.
    I also installed the version 11.1.1.2.0 FMW using all four disks (installation and donot set up).
    I also installed the fix 11.1.1.3.0 version.
    But when I am trying to run config.bat then it stops in the field of the creation to 0%, nothing happens, process sleeps:
    He created the field of size 9,23 mb and it displays "DOMAIN CREATION FAILS" after a long period of approximately 900 min.


    I also checked the path... It contains no special characters.



    Any ideas?

    You did not follow the instructions in the other links. Not at all. If you did, you would know:

    First of all, you need to use JDK 1.6
    Second of all, you have to match to the FMW WLS version you want to use (you should use 11.1.1.4, is told by the way).

    You should:

    (1) install JDK 1.6
    (2) installation of WebLogic 10.3.4 (or, if you want to use FMW 11.1.1.3, install WLS 10.3.3)
    (3) install FMW 11.1.1.2
    (4) install 11.1.1.4 patch (or 11.1.1.3)
    (5) proceed with your configuration.

    John

  • Starting Cluster Oracle 11 GR 2 sequences

    Hello

    What is RAC Oracle 11 GR 2 services startup sequences?

    Hello

    The starting 11 GR 2 Oracle clusterware sequence from Oracle high availability Services Daemon ohasd

    See this link for more details :)
    http://www.Oracle-home.ro/Oracle_Database/RAC/11gR2-Clusterware-startup-sequence.html
    Or
    From Metalink ID 1053147.1: 11 GR 2 Clusterware and Grid Home

  • automatic creation of navigation sequences does not

    I'm having the same problem with the TCS that PaulB1234 described in the General Discussion forum, except that I'm generating HTML output and I did only one book of FM in the project. When I click on "auto-create browse sequences of TOC", the list of sequences of exploration remains empty. Assistance of HR says to click "Yes" to the dialog box "to browse sequences", but no dialog box is displayed.

    PaulB1234 wrote:
    "I use RoboHelp 7 and FrameMaker 8 in the Technical Communication Suite. I added three FrameMaker 8 files based on my RH 7 project and I converted table of contents for each book. I then added three TOC TOC placeholder by default for the FrameMaker TOCs so that all three tables of contents would be generated in WebHelp output. Everything works well.

    "But when I choose" tools > sequence editor to browse ", click on the 'create automatically using TOC' button and choose the default table of contents to the"automatic creation of sequences to browse Using TOC"dialog box, some sequences don't appear in the list of browse sequences.". I tried selecting other TOCs also who were converted from the FrameMaker TOC and that no longer works.

    "What I am doing wrong? Or is there another step before that? Or is this a bug in HR? »

    Thank you! After doing a Force update, I was able to generate automatically the sequence to browse the table of contents.

    I'm not familiar with the sequences of travel as such. We are trying to replace a WWP default feature that allows the user to scroll through all the sections in order. The order to browse automatically created by HR provides similar functionality, but you can pass only through topics in a single chapter. There is a dropdown of the chapters so that you can select a different, but they are in alphabetical order, not sequential order. Therefore, it is difficult to go through aid 'page by page' somehow.

    Is it possible to put in place-to-end navigation? During this time I'll take a look at the available commands.

  • That need GG to reproduce the sequence

    Hi all

    We have sequences that create values used for the primary key. We are on the process of creation of replication between Oracle databases.

    I was going through the documentation, it contains some steps which is mainly for the initial loading of data. (Installation of Support for Oracle in Oracle Installation and Configuration Guide 12.1.2 sequences)

    My question is that I have to follow these steps for change also online synchronization? Or we can jump?

    Thank you

    Basu

    Hi Ben,

    Oracle GoldenGate supports replication of the Oracle sequences. But we must be aware of some issues, replication of sequences are supported by.

    1. change Data Capture (CDC) - synchronization of change online.

    2. the batch where the control points are not maintained.

    But it is not supported for the bottom.,.

    1. the first charges.

    2. When you configure two-way replication (bidirectional).

    That's why in the Oracle documentation, it was referred to as.,

    To support Oracle sequences, you must install some procedures database.

    These procedures supports the command FLUSH SEQUENCE of Oracle GoldenGate

    which issue you immediately after you start the Oracle GoldenGate dealt for the first time

    (usually when you perform the initial data synchronization process).

    Kind regards

    Veera

Maybe you are looking for