Disadvantages of using sequence

Hi
Please let me know the disadvantages of using sequences.
Thank you

Massimo Ruocchio wrote:
I dislike that a sequence is called even if it doesn't need to be called:Why?
Because you lost numers?
There are many other scenarios in which you loose sequence's values, as I've already wrote, so if per your requirements you have not to loose values you simply cannot use a sequence, otherwise you can use it and there are no disadvantages...
Generally speaking I like or dislike many things: food, people, football (soccer) players, etc. But I cannot like or dislike a tool. I use it if it fits my needs otherwise I don't use it ;)
Max
[My Italian Oracle blog|http://oracleitalia.wordpress.com/2010/01/31/le-direttive-di-compilazione-pragma/]
I agree with michaels. It is a waste to generate sequence numbers when there is no need to generate them.
It's not because there are gaps, but because those gaps could be avoided.
Furthermore it could cause a performance problem, especially if the sequence is not cached or the cache is small and if you are in a RAC environment.
Of cause this issue can be circumvented with a different application logic. I myself use sequences mainly in triggers and avoid calling them directly.
However it would be nice if some smarter optimizer logic, would avoid fetching new sequence values, putting them in the buffer chache...ageing out other sequences because of that, etc.
"Dislike" is a good word for it. it's not a real problem/issue, but something that could have been implemented smarter, but wasn't.

Similar Messages

  • Disadvantages of using "0" zero as first value in a generated sequence

    Does anyone have any experience with the benefits/disadvantages of using a value of 0 "zero" as the first value generated in a sequence that is also populated in a table. My past experience has always used the values of 1 "one" as the first generated value from a sequence.
    Thanks

    Benefit: You get use one "more" number from the list of values that can possibly be generated by the sequence. If you are start from '1', you have missed out on '0' :-)
    Disadvantages: If any of the queries have predicate like "sequence_generated_column_value > 0" and that your sequence starts from zero, the record with sequence_generated_column_value=0 will not appear in result set for that query (assuming it satisfies other conditions).
    May be there are many mores benefits/disadvantages to add to this list :-)

  • How to use sequence in MS sql server?

    In Oracle DB we use sequence like that:
    SequenceImpl s = new SequenceImpl("customer_seq", getDBTransaction());
    Integer next = (Integer)s.getData();
    setId(new Number(next.intValue()));
    But there is no sequence in sql server ,how can I do?
    Thank you~~

    MS SQLServer have a IDENTITY column property and UNIQUEIDENTIFIER data type that is somewhat similar to Oracle's sequence. I don't know whether your table contain either of these, or you just want to set sequential number to a column.
    Below is some info about IDENTITY and UNIQUEIDENTIFIER you may already know since they are in SQLServer Book.
    IDENTITY property: You can define IDENTITY property on a numeric column. You can set the seed and increment on this column property very much like Oracle's sequence. The only thing I think it does not have is the "nextval". You can use IDENT_CURRENT function or @@IDENTITY after an INSERT or SELECT INTO to get the last value generated. Of course you can use this value and add the increment to get the next
    value but it not the same as seqname.nextval which keep incrementing each time you call it. Getting the current identity value and adding the increment your self will not work for multiple sessions with pending
    insert. Another thing about column with IDENTITY property is that you cannot insert value into this column (i.e, omit it in your insert statement values) unless IDENTITY_INSERT is on, but only one table in a
    session can have IDENTITY_INSERT to be turned on.
    If you don't need to know the next seq value, then IDENTITY work similar to Oracle sequence. Execute select after postchanges or commit will have system generated values. If you need to get next value before insert, Sung suggest using SEQ_TABLE and managing the next value (write a database function to mimic Oracle'
    s nextval).
    UNIQUEIDENTIFIER datatype: UNIQUEIDENTIFIER is a 16-byte hexadecimal number indicating a globally unique identifier (GUID). The GUID is useful when a row must be unique among many other rows. You could use NEWID() to create a value of type uniqueidentifier or calling some API function that returns a GUID. The advantage of using uniqueidentifier is that the values generated by NEWID function or application GUID are guaranteed to be unique throughout the world. The disadvantage of using uniqueidetifier is that it is long and obscure, random, difficult for user to remember or type correctly. It is 16 byte, which is large compare to other datatype such as 4-byte integer.
    Thanks,
    Yvonne

  • What are the drawbacks or disadvantages of using LSMW

    Hi All,
    Can anyone tell me what could be the possible disadvantages of using LSMW and also some disadvantages of BAPI.
    Regards,
    MD.

    Hi MD.
    I would like to suggest a couple of disadvantages of LSMW.
    Here are a few scenarios------>
    1. Time consumption -
    > IDOC processing plays a vital role.  The changes made to the IDOC is therefore very time consuming.
    2. In term of BAPI -
    > Incomplete in terms of input fields of a particular transaction, rather it is not always complete.
    3. In terms of Direct Input -
    > No enjoy transactions and incomplete in terms of input fields of a particular transaction.
    4. In terms of Batch input -
    > Slow in terms of new recordings to be done, but BDCs are much simpler in that terms.
    This factor also depends upon the user settings, The kind of processing which is foreground and background.
    Hope that's usefull.
    Good Luck & Regards.
    Harsh Dave

  • How to use Sequence in Forms

    Hi,
    I have an Empno Column, At the time of Opening a Form The Empno Will be displayed by using Sequence.
    If the User doesn't save the Form Then the Empno Generated number will be changed.
    How to write the code to get sequence numbers at Empno columns by using Sequence?
    Thanks & Regards,
    Hari Babu

    Ok, I understand now your question. Since the oracle sequence is commited in a separate transaction, it is not possible to get the no-gap sequence, considering your example. In the other hand, if you don't commit immediately, than two concurrently opened forms could use the same sequence number, so you'll get the duplicate key!
    If you're sure that this couldn't happen, you can manage your own sequencing, storing them in another table. Let's say you reached seq 999: entering the form, you'll read from your sequence table 1000, increment to 1001, and assign it to empno, but without commiting. Next time, you'll get the same number, until you commit form, and at the same time, change in seq table. So another will get 1001.
    Downside of this approach are, as mentioned before, concurrent sessions, which will get the same sequence.

  • Comenting code - style - how to keep coments where you want them - without using sequences

    Silly question maybe about style of commenting.
    Basically i like to use sequence boxes to keep comments on my diagram beside the bits of code that they refere to - otherwise when you use diagram cleanup (which i'm afraid i use all the time) they go anywhere.  This is good - except that i found especially when doing FPGA programming the sequence boxes reduce the amount of parralelism that can go on - since the 'box' needs to finish before any of the outputs can be used.  Is there some other method i should be using instead of sequence boxes to keep text beside elements - without enforcing that a set of elements are fixed in one place?
    Solved!
    Go to Solution.

    I usually use labels of structures (loops, cases, etc) and labels of diagram constants, etc. for comments. In newer versions, we also have wire labels.
    (see also)
    What is your LabVIEW version? Also the LabVIEW 2011 cleanup does a better job keeping diagram comments together with the related code compared to earlier version.
    LabVIEW Champion . Do more with less code and in less time .

  • Error Using Sequence in Weblogic

    I tried to use Sequence object in weblogic to generate auto-imcremental integers
    for my db insert keys. I first create a mydbsequece in oracle database. Then,
    I built a class in which I obtain a dataSource using jndi to look for my dataSource.
    And then use the ds to getConnection. After I had the connection, I do the following:
    Sequence sequence = new Sequence(con, "mydbsequence");
    int i = sequence.nextValue();
    When I call sequence.nextValue() method, I got the following error message: NullPointerException
    at Weblogic.jdbc.rmi.SerialConnection.createStatement(SerialConnection.java:65).
    Does anyone know what causes this error? and How do I fix it? Please advise me
    on this. Thank you very much.
    Qin

    Qin Ding wrote:
    >
    I tried to use Sequence object in weblogic to generate auto-imcremental integers
    for my db insert keys. I first create a mydbsequece in oracle database. Then,
    I built a class in which I obtain a dataSource using jndi to look for my dataSource.
    And then use the ds to getConnection. After I had the connection, I do the following:
    Sequence sequence = new Sequence(con, "mydbsequence");
    int i = sequence.nextValue();
    When I call sequence.nextValue() method, I got the following error message: NullPointerException
    at Weblogic.jdbc.rmi.SerialConnection.createStatement(SerialConnection.java:65).
    Does anyone know what causes this error? and How do I fix it? Please advise me
    on this. Thank you very much.
    QinSequence is a non-standard JDBC object. It is an Oracle-specific class, which presumably
    takes a standard java.sql.Connection in it's constructor. Oracle has repeatedly created
    such new classes with methods claiming to take java.sql.* arguments, but in fact they
    require an Oracle-specific class. In this case, however, we might succeed anyway if
    we dig some. Can you show me the entire stacktrace of the exception?
    Please take the attached jar file, and put it in front of all the weblogic stuff
    in the server's classpath, and repeat the problem and show me the new exception.
    From the line, I am assuming you're on the 6.1 version of WebLogic. If not, forget the
    jar, and let me know.
    Joe
    [61rmicon.jar]

  • Using sequence  in view

    hi gurus
    SQL> create view v1 as select s1.nextval from dual;
    create view v1 as select s1.nextval from dual
    *+
    ERROR at line 1:
    ORA-02287: sequence number not allowed here
    Are there only workaround?
    Thank you!

    There are some restrictions on using sequences you will want to know about
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/views.htm#sthref3092

  • USING SEQUENCE IN PACKAGE SPEC

    I Want to Use Sequence.NEXTVAL & Sequence.CURRVAL throughout the package. How can i declare the global sequence variable and make them available for all the stored procedures inside the package ?
    Any help highly appreciated..
    Thank you all in advance

    Data Boy wrote:
    No i know that but using directly SEQUENCE.CURRVAL inside the Insert statement is not a good practice.
    We need to declare inside the procedure a variable and then fetch the SEQUENCE.CURRVAL into that variable
    and use that variable inside the insert statement. But we that variable scope will be available only inside that procedure.
    if i want the same CURRVAL in another stored procedure. How can i get it ..that is my Question.What exactly are you trying to achieve?
    If it's a case of needing to know the value of the sequence number assigned to an inserted record you would typically use the RETURNING clause on the insert statement...
    SQL> create table temp (id number, val varchar2(20));
    Table created.
    SQL> create sequence temp_seq;
    Sequence created.
    SQL> ed
    Wrote file afiedt.buf
      1  create trigger trg_temp before insert on temp
      2  for each row
      3  begin
      4    select temp_seq.nextval into :new.id from dual;
      5* end;
    SQL> /
    Trigger created.
    SQL> set serverout on
    SQL> declare
      2    v_num number;
      3  begin
      4    insert into temp (val) values ('Fred') returning id into v_num;
      5    dbms_output.put_line('ID inserted was: '||to_char(v_num));
      6  end;
      7  /
    ID inserted was: 1
    PL/SQL procedure successfully completed.
    SQL> select * from temp;
            ID VAL
             1 Fred
    SQL>

  • Using Sequence in ODI

    Hi I am very new to this tool can anyone tell me how to use sequence and populate Primary key in my Oracle target table. I am doing File to Oracle Mapping.
    I am using ODI sequence but i am getting errors like:
    933 : 42000 : java.sql.SQLException: ORA-00933: SQL command not properly ended
    and also delete previous check sum in Session Control
    Need ur reply asap

    Thnx Madha!
    I have change my KM to IKM SQL Control Append but the problem still persists.
    I am getting the same error message in the control workflow (~Operator Window).
    1] Control-<TGT_SECURITYSEGMENT_DIMENSION>-Create Check Table and also
    2] Control-< TGT_SECURITYSEGMENT_DIMENSION>-delete previous check sum
    The Description of the same is:
    create table Exception getObjectNameDefaultPSchema("L", "SNP_CHECK_TAB", "W") :
    CATALOG_NAME VARCHAR2(100 CHAR) NULL ,
    SCHEMA_NAME VARCHAR2(100 CHAR) NULL ,
    RESOURCE_NAME VARCHAR2(100 CHAR) NULL,
    FULL_RES_NAME VARCHAR2(100 CHAR) NULL,
    ERR_TYPE VARCHAR2(1 CHAR) NULL,
    ERR_MESS VARCHAR2(250 CHAR) NULL ,
    CHECK_DATE DATE NULL,
    ORIGIN VARCHAR2(100 CHAR) NULL,
    CONS_NAME VARCHAR2(35 CHAR) NULL,
    CONS_TYPE VARCHAR2(2 CHAR) NULL,
    ERR_COUNT NUMBER(10) NULL
    and error is :
    922 : 42000 : java.sql.SQLException: ORA-00922: missing or invalid option
    [Note: The above create table script is generated by CKM Oracle Knowledge Module].
    I am using CKM Oracle KM for the Primary key constraint in My target Oracle Table. I think the Problem is somewhere else.
    Please Help.

  • Using sequence in sqlldr

    hi
    can we use already existing db sequence in sqlldr control file
    regards
    kedar
    attached is control file but i want to use nextkey_seq to populate client_id
    LOAD DATA
    INFILE 'COMM.csv'
    APPEND
    INTO TABLE COMMUNITY_REGISTER
    FIELDS TERMINATED BY '~' OPTIONALLY ENCLOSED BY '"'
    TRAILING NULLCOLS
    (CLIENT_ID,
    SURNAME,
    DATE_OF_BIRTH DATE "YYYYMMDD" ,
    SEX,
    DATE_LAST_UPDATED DATE "YYYYMMDD" ,
    CURRENT_STATUS,
    DATE_OF_CURRENT_STATUS DATE "YYYYMMDD" ,
    INITIAL_STATUS,
    DATE_OF_INITIAL_STATUS DATE "YYYYMMDD" ,
    GP,
    GPTYPE,
    LEAD_HCP,
    STAFF_TYPE,
    NHS_NUMBER,
    COMMUNITY_ID,
    MOTHERS_ID,
    PREVIOUS_SURNAME,
    FORENAME,
    TITLE,
    ALIAS,
    STREET_NO,
    STREET,
    LOCALITY,
    TOWN,
    COUNTY,
    POSTCODE,
    HEALTH_AUTHORITY,
    PHONE_NUMBER,
    INITIAL_SECTOR,
    CURRENT_SECTOR,
    REG_DISTRICT,
    OPCS_BIRTH,
    OPCS_RESIDENCE,
    ETHNIC_ORIGIN,
    CHANGED_BY_ID,
    CHILD_HEALTH_EXISTS,
    DIAGNOSES_EXISTS,
    TEXT_EXISTS,
    SPECIAL_NEEDS_EXISTS,
    ADMISSION_EXISTS,
    CHILD_PROTECTION_EXISTS,
    NEXT_OF_KIN_ID,
    NOK_RELATIONSHIP,
    NHS_TRACE_RESULT,
    PAS_NUMBER,
    REGISTRATION_ORIGIN,
    NBH_STATUS,
    SECTOR,
    MOBILE_NO,
    AUDIT_TIMESTAMP DATE "YYYYMMDD" ,
    AUDIT_ID,
    AUDIT_ORIGIN,
    TRANSFER_CHECKED,
    LAST_ACTION,
    RECORD_STATUS,
    TRACE_RESULT_DATE DATE "YYYYMMDD"
    )

    Kedar,
    You sure can use sequence nextkey_seq.nextval in your control file (don't remember the exact syntax, but you can find it in Utilities manual for SQL*Loader

  • What does an EXEC SQL stmt do in ABAP? What is the disadvantage of using it

    hi,
    What does an EXEC SQL stmt do in ABAP? What is the disadvantage of using it?
    regards.

    sorry, question resolved.

  • What are some of the advantages/disadvantage of using FC or FCoE with a storage array (EMC)? What is Cisco's recommendation and why?

                       What are some of the advantages/disadvantages of using FC or FCoE for a storage array? What does Cisco recommend?

    This is what I'm considering:
    Power:
    1050W Seasonic 80PLUS Gold Power Supply
    Motherboard:
    ASUS, Rampage IV Extreme, 2011, SATA6, True Quad SLI/XFIRE, Extreme OC Capable
    CPU:
    Intel Core i7-4960X 3.60GHz, 2133MHz DDR3, 15MB Cache, Hex Core Processor
    System Memory:
    16GB (4 x 4GB) , PC3-19200, 2400MHz (G.Skill - x79)
    Video Adapter 1:
    NVIDIA GeForce GTX 780ti 3GB GDDR5
    Video Adapter 2:
    None
    Optical 1
    16X Blu-ray Burner - 16xBD-R, 2xBD-RW/16xDVD-R, 8xDVD-RW/48xCD-R, 24xCD-RW
    Bay Accessories 1
    NZXT Aperture M Multi-media Hub
    RAID [Requires Identical Hard Drive Selections]
    RAID 0 | 2 Disk Min. Striped set, improved performance, additional storage drive highly recommended
    Hard Drive 1
    Crucial M550 1TB 2.5" SATA III 6GB/sec Solid State Drive
    Hard Drive 2
    Crucial M550 1TB 2.5" SATA III 6GB/sec Solid State Drive
    Hard Drive 3
    Crucial M550 1TB 2.5" SATA III 6GB/sec Solid State Drive
    Sound Card
    Creative Labs Sound Blaster Z PCI Express

  • How to Use Sequence in Oracle Views

    Hi ,
    I have created a view which gives the information about the access rights which a Resource has got. for ex -
    Res1 - GYM access - member
    Res1 - Swimingpool Access - member
    I need to identify a Primary Key for this data set. So i thought that i'll use a Sequence to generate an extra column in this view.
    But when i'm using the Sequence i'm getting the following error - "ORA-02287".

    you can use sequence within view it doesnot returned error;
    create sequence t1_seq MAXVALUE 150
    START WITH 39 INCREMENT BY 1;
    SQL> insert into t1_view values(t1_seq.nextval,'dd');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from t1;
    ID NA
    10 aa
    20 bb
    30 cc
    40 dd
    4 rows selected.
    SQL> insert into t1_view values(t1_seq.nextval,'ee');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from t1;
    ID NA
    10 aa
    20 bb
    30 cc
    40 dd
    41 ee
    5 rows selected.

  • Bug when using Sequencer.setTickPosition() ?

    HI,
    I created a Track and added a few ControlChange events in ticks 0,96,192,288,384.
    This corresponds to beat indicators in a resolution of 96 (PPQ).
    I set the sequencer for a loop, starting at tick 0, and ending at tick 384.
    While the sequencer is running, I sometimes set back the tick position using Sequencer.setTickPosition(...) to one of the beat points.
    I also added a ControllerEventListener  using Sequencer.addControllerEventListener(...) which listens on the mentioned ControlChange events.
    What I see in debug logs printed by my listener, is that when I set the tick Position to say, 96, both the 0 and 96 events are being dispatched. I expected only the 96 one to fire. The 0 one is extra...
    In fact, setting the tick position to any value from 1-96 (inclusive), causes the event created with tick 0 to fire.
    If this is a feature and not  a BUG, it is implied that a ControlChange has some kind of "sustain" until the next ControlChange, than at least I expect that setting the tick position to 0-95 (inclusive)  would fire the 0 event, but at tick 96 there is already a different event.
    BTW:
    I am differentiating between the event but having them created with corresponding data1 argument set to (0,1,2,3,4).
    Can anyone explain this weird behavior?

    HI,
    I created a Track and added a few ControlChange events in ticks 0,96,192,288,384.
    This corresponds to beat indicators in a resolution of 96 (PPQ).
    I set the sequencer for a loop, starting at tick 0, and ending at tick 384.
    While the sequencer is running, I sometimes set back the tick position using Sequencer.setTickPosition(...) to one of the beat points.
    I also added a ControllerEventListener  using Sequencer.addControllerEventListener(...) which listens on the mentioned ControlChange events.
    What I see in debug logs printed by my listener, is that when I set the tick Position to say, 96, both the 0 and 96 events are being dispatched. I expected only the 96 one to fire. The 0 one is extra...
    In fact, setting the tick position to any value from 1-96 (inclusive), causes the event created with tick 0 to fire.
    If this is a feature and not  a BUG, it is implied that a ControlChange has some kind of "sustain" until the next ControlChange, than at least I expect that setting the tick position to 0-95 (inclusive)  would fire the 0 event, but at tick 96 there is already a different event.
    BTW:
    I am differentiating between the event but having them created with corresponding data1 argument set to (0,1,2,3,4).
    Can anyone explain this weird behavior?

Maybe you are looking for