Can a sequence generate negative numbers?

Hi
Thank you for reading my post
i think my sequence generate negative numbers , is it possible ?or somewhere in my application is incorrect ?
  CREATE SEQUENCE  "HR"."GLOB_SEQ"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 5 NOCACHE  ORDER  NOCYCLE ;is there anything that i made wrong which caused the negative numbers in my edit box ?
type of my category_ID is number.
Thanks

Generally speaking yes you can generate negative numbers:
SQL> create sequence seq1 increment by -1;
Sequence created.
SQL> select seq1.nextval from dual;
NEXTVAL
-1
SQL> /
NEXTVAL
-2
But if you have defined minvalue as 1 it is impossible because:
SQL> create sequence seq1 increment by -1 minvalue 1 maxvalue 1000000 start with 1;
Sequence created.
SQL> select seq1.nextval from dual;
NEXTVAL
1
SQL> /
select seq1.nextval from dual
ERROR at line 1:
ORA-08004: sequence SEQ1.NEXTVAL goes below MINVALUE and cannot be instantiated
SQL>
So most probably someone simply inserted a row with negative values knowing that they'll never be in conflict with sequence generated values, or your code is buggy :)
Generally for surrogate keys (assuming this is your case) you don't care what values they have.
Gints Plivna
http://www.gplivna.eu

Similar Messages

  • Why does Random.nextInt() generating negative numbers?

    As mentioned in the documentation, Random.nextInt() should return a pseudorandom, uniformly distributed int value between 0 (inclusive) and n (exclusive), and n must be positive. This means that we shouldn't expect any negative random number as an outcome. However, the fact is that when I was implementing this method to my program, negative numbers was generated. Why is it so? And how do I fix this problem if I need only positive random integers? Thanx!

    As mentioned in the documentation, Random.nextInt() should return a pseudorandom, uniformly distributed int value
    between 0 (inclusive) and n (exclusive), and n must be positive.You're confusing Random.nextInt() and Random.nextInt(int n).

  • After Yosemite install I can no longer get negative numbers in parenthesis in excel. Any one else having this issue?

    Excel negative numbers not appearing in parenthesis

    I have had similar problems.  I uninstalled Office and with the help of Microsoft reinstalled Office.  Excel still won't let me format negative numbers.  I called Apple and they sent me to this discussion.  I have not seen any answer.

  • Sequence generating duplicate numbers

    Hi guys,
    this might be more of a DBA question type... we had a situation where we copied data (once full schema and other time only tables ) from one database to another but ended up having sequence problem because new sequence was generating numbers which were lower than previousley generated one !
    I wonder if anyone had similar problem or know what could be causing it.
    when we copy full schema this happens to random table/sequences.
    Thanks for reading.
    Ali

    The sequence skipping behaviour is seen when cached sequences are exported.
    From the Oracle utilities manual
    >
    If transactions continue to access sequence numbers during an export, sequence numbers might be skipped. The best way to ensure that sequence numbers are not skipped is to ensure that the sequences are not accessed during the export.
    Sequence numbers can be skipped only when cached sequence numbers are in use. When a cache of sequence numbers has been allocated, they are available for use in the current database. The exported value is the next sequence number (after the cached values). Sequence numbers that are cached, but unused, are lost when the sequence is imported.
    >
    Hope this helps
    Varad

  • Is anyone having trouble using parenthesis to show negative numbers in excel after upgrading to Yosemite?

    Since upgrading to Yosemite, I can no longer reflect negative numbers with parenthesis using excel.  All of my existing spreadsheets also no longer show parenthesis, creating formatting problems.  Is anyone else experiencing this and is there a solution?

    I suggest you post your question to Microsofts own forums for their Mac software as it's their product you're having issues with
    http://answers.microsoft.com/en-us/mac

  • Issues with Sequence Generator

    I'm having trouble with Sequence generator not generating continuous numbers starting from 1, each time I run the mapping.
    I want the Sequence to start from 1, each time the mapping is run. For this to happen, I'm using a pre-mapping operator which uses an oracle procedure to reset the sequence.
    But, the sequence generates the numbers from some weird number, say 3508 and then jumps to 5006 and so on. I'm not able to track what's wrong with the sequence. I have stopped the caching in Sequence but still it hasn't helped. I'm sure and have verified that the procedure being used to reset the sequence is running fine.
    Please suggest some additional parameters/properties at OWB level to be checked for the sequence, if any OR any thoughts on why the sequence is not starting from 1. Thanks in advance.
    Thanks,
    Sachin
    Edited by: 850549 on Apr 23, 2011 11:43 AM
    Edited by: 850549 on Apr 23, 2011 11:44 AM

    Could you check whether the sequence you use has a cache value greater than 1 defined in the database. This way if your database regularly should be stoped, e.g for offline backup, you'll loose the sequence values that were unused in memory at that time. That way the gaps in your surrogate ids would be explainable.

  • Import image sequence including negative frame numbers:  -072 thru 300

    I use Quicktime pro to create movie clips from 3D frame stacks. I then use the QT clips in final cut studio to do my editing.
    my 3D app has the capability of generating "negative" frames..that is, frames prior to 0. You can use this when you have a scene all set up, and want to add something which happens before all the other things you've set up; rather than time-shifting everything else foreward, you simply add the new element prior to the 0 point.
    QT Pro appears unable to cope with this. It sees the frames with negative frame numbers as being part of a different sequence, so that it will pull in from -072 thru -001, then stop. it also will begin with frame -001, ending on -072, making the clip appear backwards when it is played.
    Clicking on the Name column so that -072 is first, doesn't make a difference.
    Is there a workaround to this from the Quicktime end of things?
    thanks!
    r

    Not that I'm aware of.
    QuickTime Player Pro image sequence files must be "sequential" and it will import in that order.
    "Negative" numbers are not placed before "positive" values and you'll need to rename the files prior to import.
    Sorry.

  • HFM 9.3 - FR Studio - can't format negative numbers with minus sign prefix?

    How can negative numbers on an account balance report be made to appear with a leading minus sign??
    This is a necessary requirement for generating an export file for loading to our new Tax software, but does not appear to be a format option.

    Have you tried going into Format Cells - Number - Negative Number Symbols - and typing a minus sign in the prefix box?

  • Can anyone tell me how to Format cell values in numbers? I am wanting to make any negative numbers in brackets.

    Anyone able to help?

    You might want to post questions like this over on the Numbers community since it's more likely you'll find expertise there.
    However, this one I can help with.  If not already showing, you need to turn on the Inspector in Numbers.  You do that by clicking on the Inspector icon in the upper right, showing the inspector box highlighted in red below:
    Now select the cell(s) you want to format and click on the fourth tab (the one with the "42" in a box).  If want no currency sign, select number as your format, while if you want a currency symbol select currency as the format.
    Next to the "Decimals" option is the box in which you can select your "negative" format--you have four options for showing negative numbers, two of which will place negative numbers in parenthesis.
    Note that the inspector box controls a number of options and settings in Numbers. 
    If you used to working with Excel you have to understand that Numbers works entirely differently and will have more than a bit of a learning curve. 
    Generally I find Numbers is the weakest of the iWork offerings.  It is a useful program if you need a heaviliy formatted presentation of pure spreadsheet data, though if you want formatted spreadsheets in a mainly text report the Word/Excel combination works better.
    The program also falls short in a number of areas vs. Excel if your spreadsheet needs go beyond the basic.  It certainly isn't the most efficent at dealing with a large spreadsheet (and, in fact, the fact the default templates all have only a few rows is a good hint that this might not be the product for that megasheet :-) ).
    But if you just have basic spreadsheet needs it certainly can do the job.

  • How to generate unique numbers

    hi all,
    I want to generate unique numbers always starting from 1 using a single sql query and I dont want to use a sequence and i dont think rownum will be helpful for generating unique numbers in all cases . how to do this ?
    thanks & regards,
    kumar.

    If two users get the MAX from temp, they would be updating with the same value for two different rows.If TEMP is a genuine temporary table, this is not an issue, because the data in a temporary table is only visible within a session.
    The big problem with this approach is the mutating table one: we cannot issue the requisite select statement from a BEFORE INSERT trigger. So this solution is only going to work with a view and an INSTEAD OF INSERT trigger.
    Another, more workable, solution is to use a code control table. This can be (should be) another temporary table, with one row holding one column - next value for TEMP.ID. Normally we would rule out such a solution because it serializes access to the inserted table, but as this is only on a per session basis, it doesn't matter.
    CREATE OR REPLACE TRIGGER tmp_bir BEFORE INSERT ON temp1 FOR EACH ROW
    DECLARE
      ln NUMBER;
    BEGIN
      SELECT nvl(code1.next_id,1) INTO ln
      FROM code1;
      :NEW.id := ln;
      UPDATE code1
      SET    next_id := ln+1;
    END;Beware: coded freehand, so may need debugging.
    Cheers, APC

  • Clarification on the limitation of sequence generator in T-SQL

    Hi, I found this limitation of sequence numbers for T-SQL:
    "If there are multiple instances of the NEXT
    VALUE FOR function specifying the same sequence generator within a single Transact-SQL statement, all those instances
    return the same value for a given row processed by that Transact-SQL statement. This behavior is consistent with the ANSI standard."
    From this link:  http://technet.microsoft.com/en-us/library/ff878058.aspx
    Does this mean that if we want to have different value generated then we can't use it in multi-threading environment whereby multiple instances / processes are calling the same T-SQL code that generate the sequence numbers using the
    NEXT VALUE FOR function?
    My understanding of the above might not be correct, any sample example to illustrate this limitation? 
    Thanks

    Hi
    This is the meaning of the comment in the article.
    If you are using in a single t-sql
    statement several times (NEXT VALUE FOR) then it will act as you use the same value. This is in-design :-)
    try this for example:
    select (NEXT VALUE FOR MySequenceName),(NEXT VALUE FOR MySequenceName),(NEXT VALUE FOR MySequenceName) -- same value several times
    But you can use (NEXT VALUE FOR) several time like this:
    DECLARE @QQ_01 int, @QQ_02 int, @QQ_03 int, @QQ_04 int
    SET @QQ_01 = NEXT VALUE FOR MySequenceName;
    SET @QQ_02 = NEXT VALUE FOR MySequenceName;
    SET @QQ_03 = NEXT VALUE FOR MySequenceName;
    SET @QQ_04 = NEXT VALUE FOR MySequenceName;
    SELECT @QQ_01,@QQ_02,@QQ_03,@QQ_04 -- different valus
    Hope this clarify things :-)
    [Personal Site] [Blog] [Facebook]

  • Uni project methods & negative numbers arrghhh

    Hi there i have written a program for uni it creates a random number & gives the user 3 guesses at getting the number before giving them a message saying they have lost and revealing the actual number. So far so good . I managed to get this working but the next part of the project requires me to use a method which gives the user a message giving them a hint. The hint tells them whether they are hot, warm, cold etc.
    I have tried to implement this in my program using this code but its not working im getting 3 messages like
    ERROR: 'class' or 'interface expected
    Also i think my use of negative numbers is wrong i can remember someone telling me you have to change the negative number into a positive before u can manipulate it or something like that.
    Anyway any help would be greatly appreciated.
    import javax.swing.*;
    import java.util.*;
    public class Coursework1{
         public static void main(String args[]){
              int randomnumber,usersguessint,checkguess,guessvalid,attempts;
              String usersguess,output,close;
              boolean match;
              //create random number generator
              Random numGenerator = new Random();
              //generate a random number between 1 & 10 inclusive
              randomnumber = Math.abs(numGenerator.nextInt(9))+1;
                   //ask user for his first guess
                   usersguess=JOptionPane.showInputDialog("Please enter your guess between 1 & 10");
                   //convert users guess to integer
                   usersguessint = Integer.parseInt(usersguess);
                        //initialize variable attempts
                        for ( attempts = 0; attempts < 2; attempts++ ) {
                        //validate input
                        while (usersguessint<1||usersguessint>10){
                        usersguess=JOptionPane.showInputDialog("You entered an incorrect number \nPlease enter a numberbetween 1 & 10");
                         //convert users guess to integer
                        usersguessint = Integer.parseInt(usersguess);
                        } //end while loop
                             //call boolean method
                             match = checkGuess(usersguessint, randomnumber);
                             if (match==true){
                             //display text area in JoptionPane
                             output="You won";
                             JOptionPane.showMessageDialog(null,output,"You Won",JOptionPane.INFORMATION_MESSAGE);
                             break;}
                             else{
                             //call boolean method
                             close = howClose( usersguessint, randomnumber);
                             output="You were"+close;
                             JOptionPane.showMessageDialog(null,output,"hint",JOptionPane.INFORMATION_MESSAGE);
                             output="Try again";     
                             usersguess=JOptionPane.showInputDialog("Try again");
                             usersguessint = Integer.parseInt(usersguess);
                                  }     //end if
                   } //end for
              }//end main
                             //user defined method (chechguess)
                             public static boolean checkGuess(int usersguessint,int randomnumber){
                             boolean match = false;
                             if (usersguessint == randomnumber){
                             match = true;
                             return match;
                             }//end method
                             //user defined method (howClose)
                             public static String howClose(int usersguessint,int randomnumber){
                             String close
                             int difference;
                             difference = randomnumber-userguessint
                             if((difference<2)&&(difference>-2)){
                                  if((difference<3)&&(difference>-3)){
                                       if((difference<4)&&(difference>-4)){
                                            close="cold";
                                       }//end if
                                  else{
                                       close="warm";
                                  }//end if     
                             else{
                                  close="hot";
                             return close;     
                             }//end method
         }//endclass

    Yep, faulty as designed.
    try this:public static String howClose(int usersguessint, int randomnumber) {
              int difference;
              difference = randomnumber - usersguessint; // <---
              if ((difference < 2) && (difference > -2)) {
                   return "hot";
              if ((difference < 3) && (difference > -3)) {
                   return "warm";
              return "cold";
         }// end method

  • CMP PK Sequence generated by Bean Self Cache !!

    Hi All,
    In WL6.1, one can mention the name of the sequence and the DB in the cmp-rdbms-jar.xml
    to use the sequence generated number to use as a primary key.
    Though my work is being done by the WL server but still WL server is hitting the
    DB for each insert.
    There are a couple of discussions listed on theserverside.com, but most of them
    fail for a clustered environment.
    Can anyone please suggest me a solution where the WL server would cache the keys
    instead of hitting the DB for each insert ?
    Thanks in advance for your help !!
    Regards
    -Rais

    Hi,
    I performed a test and ran 3 scenarios(inserting 1000 records).
    1. SEQUENCE INCREMENT BY 10 And key-cache-size = 1.
    Time taken = 13 seconds
    Records were inserted as 1,11,21,31.....
    2. SEQUENCE INCREMENTED BY 10 And key-cache-size = 10
    Records were inserted as 1,2,3,4,5...
    Time = 8 seconds
    3. SEQUENCE INCREMENTED BY 1 And key-cache-size = 10
    I got the duplicate primary key problem.
    The behaviour in case 2 is ambiguous to me...I was expecting the records to be
    inserted as 1,11,21,31.....
    Can anyone please clarify ??
    Thanks
    -Rais
    "Rais" <[email protected]> wrote:
    >
    Hi Rob,
    The weblogic Docs and the DTD says that "key-cache-size" should be equal
    to the
    INCREMENT VALUE of the Sequence in DB.Lemme point out what I have interpreted
    from that.Please correct me if I am wrong.
    lets say my sequence is
    CREATE SEQUENCE TEMP_SEQ INCREMENT BY 2.
    And my key-cache-size value is also 2.
    I believe that by keeping these two values equal,records would be inserted
    into
    the DB as 1,3,5,7......
    But in a clustered environment,each CMP would still be hitting the DB
    to get the
    sequence number.
    What I mean to say is key-cache-size is actually not meant for caching
    the sequence
    numbers.
    Even if it is ,how would the servers in the cluster maintain the same
    state of
    their individual cache same ??
    Regards
    -Rais
    Rob Woollen <[email protected]> wrote:
    Did you set a key-cache-size in your CMP deployment descriptor?
    -- Rob
    Rais wrote:
    Hi All,
    In WL6.1, one can mention the name of the sequence and the DB in thecmp-rdbms-jar.xml
    to use the sequence generated number to use as a primary key.
    Though my work is being done by the WL server but still WL server
    is
    hitting the
    DB for each insert.
    There are a couple of discussions listed on theserverside.com, butmost of them
    fail for a clustered environment.
    Can anyone please suggest me a solution where the WL server would
    cache
    the keys
    instead of hitting the DB for each insert ?
    Thanks in advance for your help !!
    Regards
    -Rais

  • Generating batch numbers

    Hi All,
    I have a requirement to generate batch numbers for every 200-item records of source file.
    I have to populate to the target filed with generated batch number + the item sequence number (both are not available in file).
    Thanks,
    venu.

    Hi Venu,
    You can go with the option of Number Range objects in the ABAP . So from the mapping you can call this lookup table and generate the new number . For this you need to use JCO call . It is a kind of RFC lookup
    This number range object you can maintain in the XI integrtaion Server(ABAP stack ) itself. To avoid overheads of call to the SAP r/3 systems. And also, while transporting, it is not required to change the IP address etc in the JCO call. 
    And one more option is maintaining Java Tables. with property files etc..
    Hope this helps,
    REgards,
    Moorthy
    Message was edited by: Krishna Moorthy P

  • Random negative numbers

    A friend has asked me to implement a class that will produce random integers throughout the entire range of possible integer values. I know how to do this using Random() and generate "positive" numbers, but I can't figure out the algorithm(if there is one) to include the other 2 billion "negative" integer values.
    Ant help is greatly appreciated!

    But, you don't need a minus sign before it! nextInt() already returns a random integer through the entire range of positive and negative integers. It does exactly what you want!

Maybe you are looking for

  • Problem with NT4 and 120 Gb. raid partition

    Hi, My motherboard is a 694D Pro AR (MS-6321, rev 1) This has onboard Firewire (IEEE 1394) and onboard RAID (via the Promise Fastrak100 RAID controller built on the board). The Operating system is in an IBM 45 GB. disk. attach to IDE 100 controller 1

  • Safari 2.0.4 freezes daily

    Hi I've searched for this topic but I don't see anything quite like what I've been experiencing. I recently started using Safari on a daily basis, I used to use Firefox exclusively, so I don't know how long this issue may have been hiding while the p

  • Adding text to a photo in iPhoto 08

    New to Mac and iPhoto and while laying out a birth announcmnet I wanted to add text on top f the phots to places the Apple card templates didn't allow. Is there a way to add text to a photo in iPhoto? Thanks. Message was edited by: sdenby

  • .fla saved in CS5 as CS4 won't open in CS4

    Hello. In Adobe Flash Professional CS5 (11.0.0.485) (on intel mac running 10.7.2), I set up a document, save it, and then save it as a CS4 document. I then transfer it to another Mac (ppc, running 10.5.8) and try opening it with Adobe Flash Professio

  • USPS account options

    Can anyone tell me which USPS tool/account we need for a client who will be shipping Media, Priority and Priority International?  I see the USPS Web Tools, but it looks to me like that has to do with installing and configuring the whole API, which I