Missing numbers in a sequence

I need to list all the missing numbers in a sequence. For example, in a table containing work orders, the work order numbers start from WO0001 and end at WO9999. In this some work order numbers like WO8001 may be missing. Can someone suggest me a way to extract these missing numbers?

This example uses the all_objects view and requires that you have at least as many rows in that view as in your work order table. If not, create a table with at least as many number and use that instead. The query in this example does not assume the lower and upper boundaries - it can be optimized a bit if those boundaries are hard-coded. Also, the fact that your work_order contains alpha characters (WO) had to be compensated for. Here is the idea (based on a Tom Kyte example, as usual):
sql>create table t (work_order) as
  2    select 'WO' || to_char(rownum, 'FM0000')
  3      from all_objects
  4     where rownum <= 9999;
Table created.
sql>delete from t
  2   where work_order in ('WO1000', 'WO5000', 'WO9000');
3 rows deleted.
sql>select 'WO' || missing_id missing_id
  2    from t,
  3         (select rownum + min_id - 1 missing_id
  4            from all_objects,
  5                 (select max(to_number(substr(work_order, 3))) max_id,
  6                         min(to_number(substr(work_order, 3))) min_id
  7                    from t)
  8           where rownum <= (select max(to_number(substr(work_order, 3))) -
  9                                   min(to_number(substr(work_order, 3))) + 1
10                              from t))
11   where missing_id = to_number(substr(work_order(+), 3))
12     and work_order is null;  
MISSING_ID
WO1000
WO5000
WO9000

Similar Messages

  • Find out Missing Numbers in a sequence

    Hi
    We have a table ORDH, which is having a field ORDERNO which starts from 300000. currently there are around 100 thousand records exists in this table.
    The ORDERNO value is generated from a sequence.
    We want to find out the missing (hole in the sequence) ORDERNO from the ORDH table.
    (Ex: 300654 is missing and there are lot of other order numbers were also missing)
    Is there a way to find out all the missing order numbers from this table?
    Thanks and Regards
    Murali

    Hi, Murali,
    This will show you the missing ranges of numbers between existing numbers:
    WITH     got_next_orderno     AS
         SELECT     orderno
         ,     LEAD (orderno) OVER (ORDER BY orderno)     AS next_orderno
         FROM     ordh
    SELECT     ordrno + 1          AS from_no
    ,     next_orderno - 1     AS to_no
    FROM     got_next_orderno
    WHERE     orderno     + 1     != next_orderno
    ;I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statments) and the results you want from that data.

  • Looking to write a query to give me the missing numbers in a sequence

    My query here gives me a list of numbers:
     select distinct cast(SUBSTRING(docket,7,999) as INT) from [DHI_IL_Stage].[dbo].[Violation] where InsertDataSourceID='40'
      and ViolationCounty='Carroll' and SUBSTRING(docket,5,2)='TR' and LEFT(docket,4)='2011'
      order by 1
    Gives back:
    I want to find the numbers missing in the sequence

    CREATE TABLE t1  (C INT NOT NULL PRIMARY KEY)
    insert t1 select 1 union all
     select 3 union all
    select 4 union all
    select 5 union all
    select 7 union all
    select 10 
    SELECT
      c+n FROM t1, (
      SELECT 0 n UNION ALL SELECT 1
    ) T
    GROUP BY c+n
    HAVING MIN(n) = 1 and c+n < (select max(c) from t1)
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • How can I get two missing numbers on a iTunes card

    How can I get two missing numbers on a iTunes card

    "Get help",just below the form space where I entered the code. Once I clicked "Get Help", it added another line to the form where I could enter  THE NUMBER ON THE BOTTOM LEFT CORNER on the back of the card. I entered as much of the I scratch-off code I could read, along with the serial number.

  • Selecting missing numbers in Range (missing in 1 - 10 )

    hello
    i want to get missing numbers query in a range like i want query returns only missing numbers between 1 to 10 present in a table
    thanks.
    Message was edited by:
    Rehman

    in this case if a change my range from 2 - 11 it does not works. In that case, I would use pipelined function :
    SQL> drop table rehman ;
    Table dropped.
    SQL> create table rehman as
      2  select 1 id from dual union all
      3  select 3 id from dual union all
      4  select 5 id from dual union all
      5  select 7 id from dual union all
      6  select 9 id from dual ;
    Table created.
    SQL>
    SQL>
    SQL> create or replace type TblId as table of number
      2  /
    Type created.
    SQL>
    SQL> create or replace function Tbl_rehman(p_start number, p_end number)
      2   RETURN TblId
      3   PIPELINED
      4  IS
      5  BEGIN
      6   FOR x IN p_start..p_end
      7   LOOP
      8       PIPE ROW( x );
      9   END LOOP;
    10   RETURN;
    11  END;
    12  /
    Function created.
    SQL>
    SQL> select *
      2  from   table(Tbl_rehman(1,10)) a
      3  where not exists (select 1 from rehman b where b.id=a.column_value);
    COLUMN_VALUE
               2
               4
               6
               8
              10
    SQL>
    SQL> select *
      2  from   table(Tbl_rehman(2,11)) a
      3  where not exists (select 1 from rehman b where b.id=a.column_value);
    COLUMN_VALUE
               2
               4
               6
               8
              10
              11
    6 rows selected.
    SQL> Nicolas.

  • Find missing numbers in array

    HI !
    I have an array which holds 999 different numbers between 1-1000
    (which means that 1 number between 1-1000 does not appear in the array).
    I need to find the missing number in one pass and it's easy.
    My question is:
    Do you have any idea how can I find 2 missing numbers in the array ?
    Is it possible ?
    I cant use any data structure and I need to find the missing numbers in one pass.
    Thank you

    Using array.sort() and using another array is out of the question as its inhrently banned in the "i cant use any data structure" so this is
    Homework! tut tut
    ok so far an array with 1 number missing "its easy" yeah, just add em all up and see whats missing.
    for 2 numbers missing you should take a hint from what you are studying in the course ie solving Quadratic Equations..
    shall i make snoopy beg yet??
    naw, ok here goes
    on your 1 permitted pass add up all the mumbers that are there, also have another total for the squares of the numbers
    call the numbers you are looking for A and B
    subtract the first total from what it would be if there were all 1000, call this N
    subtract the second total from what the total of the squares would be if there were all 1000, call this M
    so..
    A+B=N
    solve for B in terms of A
    so..
    B=N-A
    and A^2+B^2=M
    should i quit now???
    no, ok
    substitute B in the second equation, shuffle a bit and..
    2A^2-2NA+N^2-M=0
    recognise the terms of the quadratic and..
    A=(2N +/- (4N^2-8(N^2-M))^.5)/4
    note the +/- plus OR minus will give you 2 results, these will be the 2 missing munbers
    tahh dahh
    See maths does have some use

  • Finding Missing Numbers

    I want to find missing numbers from a column which is alpha numeric, its last five positions are numeric. At first three positions there are different combinations of alphas i.e. *'BA ','BAW','SA ','SAA' ..........* if alphas are two then 3rd position is blank. I also need it to generalised this to cover all existing alpha numeric series.
    SELECT SUBSTR (a.claim_no, 4, 5) + 1
      FROM core_business.cb_pensioner a
    WHERE SUBSTR (a.claim_no, 1, 3) = 'BA '
       AND NOT EXISTS (
                     SELECT NULL
                       FROM core_business.cb_pensioner b
                      WHERE to_number(SUBSTR (b.claim_no, 4, 5)) =  to_number(SUBSTR (a.claim_no, 4, 5)) + 1)
       order by SUBSTR (a.claim_no, 4, 5);I am getting ORA-01722 error

    You have two issues with such a task.
    Problem 1 is how to convert the trailing part into a number so that you can compare values.
    to_number(SUBSTR (b.claim_no, 4, 5)) works, but only if the value in b.claim_no is always a number regardless of the other column criteria.
    A statement like
    WHERE SUBSTR (a.claim_no, 1, 3) = 'BA ' /* filter 1 */
    and to_number(SUBSTR (b.claim_no, 4, 5)) > 1 /* filter 2 */
    ...might fail because your table might have a value like
    b.claimno = 'XYZ1234b'
    The way you wrote the query the database will decide which filter criteria it executes first. It might be filter1, but could also be filter2. If filter2 is executed first then you will get the error message.
    Problem 2 how to order and compare different rows, so that you can find the missing values.
    Here the analytic LEAD(LAG) function is very helpful. it will give you access to the next (or previous row).
    Both problems can be overcome.
    Here is my try, but I'm not sure if it works in your case. You might need to adapt a little.
    This should work if all the rows are numeric that belong to the specific groups. if you can have wrong data in there too, then a different approach is needed.
    with testdata as (select 'XYZ1234b' claim_no from dual union all
                select 'BA 12345' claim_no from dual union all
                select 'BA 12346' claim_no from dual union all
                select 'BA 12350' claim_no from dual union all
                select 'BAW11111' claim_no from dual union all
                select 'BAW11113' claim_no from dual union all
                select 'XYZ1234b' claim_no from dual )
    /* end of test data creation */
    select claim_no, substr(claim_no, 1,3) part1, substr(claim_no, 4) part2,
           to_number(substr(claim_no, 4)) current_num,
           lead(to_number(substr(claim_no, 4))) over (partition by substr(claim_no, 1,3) order by to_number(substr(claim_no, 4))) next_num,
           lead(to_number(substr(claim_no, 4))) over (partition by substr(claim_no, 1,3) order by to_number(substr(claim_no, 4)))
            - 1 - to_number(substr(claim_no, 4))
            as "missing_values"
    from testdata
    where substr(claim_no, 1,3) in ('BAW','BA ')
    order by claim_no;
    CLAIM_NO PAR PART2 CURRENT_NUM   NEXT_NUM missing_values
    BA 12345 BA  12345       12345      12346              0
    BA 12346 BA  12346       12346      12350              3
    BA 12350 BA  12350       12350
    BAW11111 BAW 11111       11111      11113              1
    BAW11113 BAW 11113       11113Problem 1 is solved because the where condition is always executed before the function in the select clause, especially in connection with an analytic function.
    Problem 2 is also solved by using the analytic function LEAD function. And this is fast, because you access the same table only one time. Other solution might do a subquery to fetch the value from the previous/next row. This means several accesses to the same table and is usually much slower.
    Edited by: Sven W. on Sep 20, 2010 2:32 PM

  • TS1292 I scratched my itune card and some of the numbers came off. Please advise how to get the missing numbers

    I scratched my iTunes card and some of the numbers have come off. How do I get the missing numbers?

    See this support article:
    http://support.apple.com/kb/TS1292
    If you can't get to work after perusing that page, contact the iTunes Store Support; instructions are at the bottom of that article.
    Regards.
    Forum Tip: Since you're new here, you've probably not discovered the Search feature available on every Communities page, but next time, it might save you time (and everyone else from having to answer the same question multiple times) if you search a couple of ways for a topic, both in the relevant forums and in the Apple Knowledge Base, before you post a question.

  • Insert missing numbers

    I have a data like this:
    G1, 1
    G1, 2
    G1,
    G1,
    G2, 1
    G2,
    G2,
    G2,
    G2,
    G3, 1
    G3, 2
    G3, 3
    G3,
    G3,
    G3, I have to populate the missing numbers for each group. The data should look like this:
    G1, 1
    G1, 2
    G1, 3
    G1, 4
    G2, 1
    G2, 2
    G2, 3
    G2, 4
    G2, 5
    G3, 1
    G3, 2
    G3, 3
    G3, 4
    G3, 5
    G3, 6Can it be done in SQL without using a stored procedure? Thanks.
    Kumar

    hi,
    SQL> With T As
      2  (Select 'G1' col, 1 col1 From dual
      3  Union All
      4  Select 'G1', 2 From dual
      5  Union All
      6  Select 'G1', Null From dual
      7  Union All
      8  Select 'G1', Null From dual
      9  Union All
    10  Select 'G2', 1  From dual
    11  Union All
    12  Select 'G2', Null From dual
    13  Union All
    14  Select 'G2', Null From dual
    15  Union All
    16  Select 'G2', Null From dual
    17   Union All
    18  Select 'G2', Null From dual
    19  Union All
    20  Select 'G3', 1 From dual
    21  Union All
    22  Select 'G3', 2 From dual
    23  Union All
    24  Select 'G3', 3 From dual
    25  Union All
    26  Select 'G3', Null From dual
    27  Union All
    28  Select 'G3', Null From dual
    29  Union All
    30  Select 'G3',Null From dual)
    31  Select col, row_number() Over(Partition By col Order By col)col1
    32    From T
    33  /
    CO       COL1
    G1          1
    G1          2
    G1          3
    G1          4
    G2          1
    G2          2
    G2          3
    G2          4
    G2          5
    G3          1
    G3          2
    CO       COL1
    G3          3
    G3          4
    G3          5
    G3          6
    15 rows selected.

  • Missing numbers in metadata browser under OS X Mavericks & LR5

    Every since upgrading to Mavericks my Lightroom metadata browser has had missing numbers.  It used to show the total count of photos that matched the criteria and it no longer does that.  Has anyone else had this issue or know how to resolve it?  It's not really that big of a deal but it is a constant annoyance.  I've attached a screen shot of the issue.

    Known bug in LR5 on Mavericks.
    http://feedback.photoshop.com/photoshop_family/topics/lr_5_2_os_x_mavericks_missing_photo_ count_in_library_module
    Fixed in LR5.3RC which you can download today although the final release is due soon
    http://labs.adobe.com/technologies/lightroom5-3/
    I run LR5.3RC on Mavericks with no issues yet.

  • RoboHelp 10 - Missing numbers in the Numbered List within a drop-down hotspot

    I have applied a numbered list style to a paragraph which is written in a drop-down hotspot within another drop-down hotspot in RoboHelp 10. But I observed, though the 'numbers' are displayed in the editor, they are missing from the generated output. Please suggest a solution.

    This is a known issue. Please file a bug report with Adobe: https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform&product=38
    The only workaround I know of is to use regular lists instead in nested dropdowns.

  • Standby problem - log numbers out of sequence

    Hi everyone! I am on 10.2.0.3.
    My physical standby stopped applying logs because all of a sudden the logs went out of sequence. See errors below - after seq 7975 & 7976 seq# 7974 showed up again:
    Recovery of Online Redo Log: Thread 1 Group 200 Seq 7974 Reading mem 0
    Mem# 0: /db/data3/FSPRD/stby_redo02.log
    Mem# 1: /db/data4/FSPRD/stby_redo02_02.log
    Thu Dec 18 16:14:58 2008
    RFS[23]: Successfully opened standby log 100: '/db/data1/FSPRD/stby_redo01.log'
    Thu Dec 18 16:15:01 2008
    RFS[25]: Successfully opened standby log 300: '/db/data5/FSPRD/stby_redo03.log'
    Thu Dec 18 16:15:01 2008
    Primary database is in MAXIMUM PERFORMANCE mode
    RFS[37]: Successfully opened standby log 400: '/db/data7/FSPRD/stby_redo04.log'
    Thu Dec 18 16:15:02 2008
    RFS[24]: Successfully opened standby log 200: '/db/data3/FSPRD/stby_redo02.log'
    Thu Dec 18 16:15:03 2008
    Media Recovery Waiting for thread 1 sequence 7975 (in transit)
    Thu Dec 18 16:15:03 2008
    Recovery of Online Redo Log: Thread 1 Group 100 Seq 7975 Reading mem 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)
    Thu Dec 18 16:15:07 2008
    Recovery of Online Redo Log: Thread 1 Group 200 Seq 7974 Reading mem 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
    Thu Dec 18 16:15:12 2008
    Errors in file /db/dbdump/FSPRD/bdump/fsprd_mrp0_11351.trc:
    ORA-00355: change numbers out of order
    ORA-00353: log corruption near block 2 change 4994299896 time 12/18/2008 16:14:57
    ORA-00312: online log 200 thread 1: '/db/data4/FSPRD/stby_redo02_02.log'
    ORA-00312: online log 200 thread 1: '/db/data3/FSPRD/stby_redo02.log'
    Managed Standby Recovery not using Real Time Apply
    Thu Dec 18 16:15:12 2008
    Primary database is in MAXIMUM PERFORMANCE mode
    RFS[37]: Successfully opened standby log 100: '/db/data1/FSPRD/stby_redo01.log'
    Thu Dec 18 16:15:13 2008
    Recovery interrupted!
    Thu Dec 18 16:15:13 2008
    Errors in file /db/dbdump/FSPRD/bdump/fsprd_mrp0_11351.trc:
    ORA-00355: change numbers out of order
    ORA-00353: log corruption near block 2 change 4994299896 time 12/18/2008 16:14:57
    ORA-00312: online log 200 thread 1: '/db/data4/FSPRD/stby_redo02_02.log'
    ORA-00312: online log 200 thread 1: '/db/data3/FSPRD/stby_redo02.log'
    Thu Dec 18 16:15:13 2008
    MRP0: Background Media Recovery process shutdown (FSPRD)
    Thu Dec 18 16:15:19 2008
    I of course restarted the managed recovery and everything went fine from this point on - but I could not find the root cause of this problem.
    Anybody has any ideas - or experienced this before?
    TIA.

    I'm afraid you're hitting bug 6039415 ORA-355 can occur during real time apply, the good news: there's a patch available.
    HTH
    Enrique

  • Back numbers in Oracle sequences

    We are using a J2EE based tool that uses Oracle as backend. For several purposes the tool use the oracle sequences. As per general rule the every time the sequence is referred, it generates a next higher number and returns the same for any kind of storage purposes like primary key, etc. But in rare cases we have got a previous number of the sequence instead of a next higher value. We aren't sure if that previous number was ever used before or not. But the problem is how does the oracle sequence return a previous number? e.g. we have a sequence running as 220, 221, 222, etc. then suddenly instead of returning 223 the next time, it may give the number 214 (or basically any previous number).
    Does anybody know why does that happen? What could be the possible reasons and how it can be avoided? It creates confusion amongst users and does not seem just right to get a previous number. Any help is appreciated. Thanks.

    Connection pooling should have no effect on this issue since the Oracle sequences should be cached in Oracle and not in the pooled session.
    RAC as mentioned would since each instance would have its own sequence cache: instance A values 1 - 5, instance B values 6 - 10, instance C 11 - 15.
    Then depending on which instance the user session was connected to the ticket numbers would appear to be selected from an earlier point in the sequence.
    On a non-RAC instance you can see this apparent behavior where the application gets the sequence number on the first screen and passes the value to later screens but the number is not inserted into a database table until the final screen that creates the ticket. If it takes the user longer to create the ticket than other users who started later then the ticket number would appear earlier than the earlier created tickets.
    The solution to this "problem" for non-RAC or RAC is to insert a timestamp at the time of ticket creation (or start) and to process the tickets in timestamp rather than ticket number order. After all the ticket number is just an identifier and there is really no logical reason that tickets have to be processed in ticket number order.
    If it is a political issue then you could use a dual key system. Assign one key at creation time, transaction key, and then assign the ticket number via batch based on either the timestamp of when ticket entry started or was submitted. Now the ticket numbers represent whatever order you need. You can notify the users of the ticket number via email.
    HTH -- Mark D Powell --

  • How to find Missing Numbers, simplest way

    Hi All,
    Table 1
    Invoice_books_issues
    Columns are Transaction_date,serail_no_start,serial_no_end.
    Ex Data is :
    1/1/2005...........1000.............2000
    2/2/2005...........4500.............5500
    My Invoice_table is
    Inv_no
    1908
    1005
    4502
    4589
    5509......on and on...
    so i need to get the missing nos out of the issues. like
    1000
    1001
    1002
    1003
    1004 ... note here 1005 alrady been used.
    1006
    ... on and on.
    Thanks in advance.

    something like this :
    1. create view holding surrogate numbers:
    CREATE OR REPLACE VIEW NUM_VIEW
    (NUM)
    AS
    SELECT thous.x+huns.x+tens.x+ones.x num FROM
    (SELECT 0 x FROM dual
    UNION SELECT 1 FROM dual
    UNION SELECT 2 FROM dual
    UNION SELECT 3 FROM dual
    UNION SELECT 4 FROM dual
    UNION SELECT 5 FROM dual
    UNION SELECT 6 FROM dual
    UNION SELECT 7 FROM dual
    UNION SELECT 8 FROM dual
    UNION SELECT 9 FROM dual) ones,
    (SELECT 0 x FROM dual
    UNION SELECT 10 FROM dual
    UNION SELECT 20 FROM dual
    UNION SELECT 30 FROM dual
    UNION SELECT 40 FROM dual
    UNION SELECT 50 FROM dual
    UNION SELECT 60 FROM dual
    UNION SELECT 70 FROM dual
    UNION SELECT 80 FROM dual
    UNION SELECT 90 FROM dual) tens,
    (SELECT 0 x FROM dual
    UNION SELECT 100 FROM dual
    UNION SELECT 200 FROM dual
    UNION SELECT 300 FROM dual
    UNION SELECT 400 FROM dual
    UNION SELECT 500 FROM dual
    UNION SELECT 600 FROM dual
    UNION SELECT 700 FROM dual
    UNION SELECT 800 FROM dual
    UNION SELECT 900 FROM dual) huns,
    (SELECT 0 x FROM dual
    UNION SELECT 1000 FROM dual
    UNION SELECT 2000 FROM dual
    UNION SELECT 3000 FROM dual
    UNION SELECT 4000 FROM dual
    UNION SELECT 5000 FROM dual
    UNION SELECT 6000 FROM dual
    UNION SELECT 7000 FROM dual
    UNION SELECT 8000 FROM dual
    UNION SELECT 9000 FROM dual) thous
    this one holds numbers up to 9999 - should be up to the maximum value for your invoice number.
    2.
    CREATE TABLE INVOICE
    INV_NO NUMBER(5)
    Insert into invoice
    (INV_NO)
    Values
    (1000);
    Insert into invoice
    (INV_NO)
    Values
    (4501);
    Insert into invoice
    (INV_NO)
    Values
    (4505);
    COMMIT;
    3.
    CREATE TABLE INVOICE_BOOKS_ISSUES
    SERIAL_NO_START NUMBER,
    SERIAL_NO_END NUMBER
    Insert into INVOICE_BOOKS_ISSUES
    (SERIAL_NO_START, SERIAL_NO_END)
    Values
    (1000, 1006);
    Insert into INVOICE_BOOKS_ISSUES
    (SERIAL_NO_START, SERIAL_NO_END)
    Values
    (4500, 4507);
    COMMIT;
    4.
    SQL> select * from invoice;
    INV_NO
    4501
    1000
    1005
    4505
    SQL> select * from Invoice_books_issues;
    SERIAL_NO_START SERIAL_NO_END
    1000 1006
    4500 4507
    SQL>
    select num
    from num_view nv
    where exists
    (select serial_no_start, serial_no_end from Invoice_books_issues ibi
    where nv.num >= ibi.SERIAL_NO_START and nv.num <= ibi.SERIAL_NO_END)
    and
    not exists (select inv_no from invoice inv where inv.INV_NO = nv.num)
    NUM
    1001
    1002
    1003
    1004
    1006
    4500
    4502
    4503
    4504
    4506
    4507
    11 rows selected.
    SQL>
    hope this helped.
    Mike

  • Missing numbers in Business Indicators

    Hi,
    I'm using Oracle Business Indicators for iPhone. I discovered that in some reports (which ones, I don't know but it seems that the problem only occurs with big numbers, e.g. billions and above), some numbers are missing.
    For example, 2,424,345,123.35 is shown as 242.35, that is, the numbers in the middle are missing. That is very annoying since I really don't understand the source of the bug.
    btw, I made a trace with Wireshark, and it seems that the data from the obi server to the iPhone is correct (the number is correct). I'm wondering if the iPhone app itself is not buggy (surprisingly, the last version is 1.2, in july 2008, and there was no new version for iPhone v3.0). Did anyone see that problem before.
    Regards,

    This example uses the all_objects view and requires that you have at least as many rows in that view as in your work order table. If not, create a table with at least as many number and use that instead. The query in this example does not assume the lower and upper boundaries - it can be optimized a bit if those boundaries are hard-coded. Also, the fact that your work_order contains alpha characters (WO) had to be compensated for. Here is the idea (based on a Tom Kyte example, as usual):
    sql>create table t (work_order) as
      2    select 'WO' || to_char(rownum, 'FM0000')
      3      from all_objects
      4     where rownum <= 9999;
    Table created.
    sql>delete from t
      2   where work_order in ('WO1000', 'WO5000', 'WO9000');
    3 rows deleted.
    sql>select 'WO' || missing_id missing_id
      2    from t,
      3         (select rownum + min_id - 1 missing_id
      4            from all_objects,
      5                 (select max(to_number(substr(work_order, 3))) max_id,
      6                         min(to_number(substr(work_order, 3))) min_id
      7                    from t)
      8           where rownum <= (select max(to_number(substr(work_order, 3))) -
      9                                   min(to_number(substr(work_order, 3))) + 1
    10                              from t))
    11   where missing_id = to_number(substr(work_order(+), 3))
    12     and work_order is null;  
    MISSING_ID
    WO1000
    WO5000
    WO9000

Maybe you are looking for

  • Cancel release in idoc

    Hi Friends, We are upgrading our ECC system from release 700 to 731. For one of the idoc interface we are using SHPMNT03 idoc. Post upgrade it is observed that E1EDT37 segment version is updated from 003 to 004. Biz Talk(middle ware), whose schema is

  • One application module with 3 differente data base connections

    I have 3 different servers for data base connections. The main is "sys", the second "stanby" and the third: "bdbatch". In the old application,that i m re programating, uses a properties to read the connection. If the main is not available then goes t

  • Trying to install Oracle 8i on Windows XP

    I had been trying to install oracle 8i on Windows XP with no success so far; Every time a start the setup the program just shutdown without any message. I changed the security of the Explorer to low but the result is the same. Does anybody know why?

  • Barcode and PDF document printing in SAP MII

    Hi All, I am using SAP MII 15.0, one of my requirement is to print the Barcode and PDF file automatically. I have came across the link below which tells to print the label http://scn.sap.com/community/manufacturing/mii/blog/2014/08/17/industrial-labe

  • Business partner auto code generation

    hi how to create business partner auto code generation. its based on customer group for example we have more customer group..dealer, distributor,subcontractor... here dealer and distributor group starting cardcode is - C000001,C000002,C000003..... et