Count (*) using partitioned index gives incorrect results

I have a table partitioned by hash with 4 index the.

Table name: store_assortment

clues the: idx1 (master_id), idx2 (store), idx3 (item), idx4 (request_id)

When I run this query result is 13649:

SELECT COUNT (*)

OF store_assortment

WHERE to store = 6010

ORDER BY point;

When I run this query result is 13648:

SELECT COUNT (*)

OF store_assortment

WHERE store = 6010;

I rebuild all indexes, but the results are the same. Can anyone point to a bug or something that can explain this?

I dropped and recreated the indices and values are correct now. Reconstruction did not work.

Thanks for all the help.

Tags: Database

Similar Questions

  • sdo_cs. Transform gives incorrect results...

    Hi all

    I try to convert the projection Ordnance Survey coordinates WGS84, British National Grid. When the conversion comes out all points are approximately 100 metres west northwest. The native srid is 81989 (BGSO) and I am trying to convert 8307 or 4326, all two wgs84 lat/long and give the same results.

    Is it possible the problem lies in the conversion between a Cartesian and spherical coordinate system?

    Here is the code:

    Select sdo_cs.transform (SDO_GEOMETRY (2001, 81989, SDO_POINT (367597, 80975, NULL), NULL, NULL), 8307) twice;

    which translates into:

    MDSYS. SDO_GEOMETRY (2001,8307, MDSYS. SDO_POINT_TYPE(-2.45816262176897,50.6276801063492,null), NULL, null)

    However, the returned coordinates must be:

    -2.45950270 / / 50.62750125

    All comments appreciated! Thank you.

    Yes, 10g did not have reference parameters required in the definition.

    If you're on 10 gr 2 (for example, 10.2.0.4), you can update your SRID, with the following script (if you're on 10gR 1, please let me know, first of all).

    (You can change the WKTEXT back the same way, if you cut and paste the current value of WKTEXT into a text backup file). Usually, we do not suggest to change the existing definitions, but rather to create new variants of these definitions. In this case, however, you simply change the definition of 10g in the definition of 11g, which is fine.

    SQL> update
      sdo_cs_srs
    set
      wktext =
    'PROJCS["British National Grid",
      GEOGCS [ "Ordnance Survey Great Brit",
        DATUM ["Ordnance Survey Great Brit",
          SPHEROID ["Airy 1830", 6377563.396, 299.3249646], 375, -111,  431, 0, 0, 0, 1],
        PRIMEM [ "Greenwich", 0.000000 ],
        UNIT ["Decimal Degree", 0.01745329251994330]],
      PROJECTION ["Transverse Mercator"],
      PARAMETER ["Scale_Factor", 0.9996012717],
      PARAMETER ["Central_Meridian", -2.000000],
      PARAMETER ["Latitude_Of_Origin", 49.000000],
      PARAMETER ["False_Easting", 400000.000000],
      PARAMETER ["False_Northing", -100000.000000],
      UNIT ["Meter", 1.000000000000]]'
    where
      srid = 81989;
    
    1 row updated.
    
    SQL> commit;
    
    Commit complete.
    
    SQL> select sdo_cs.transform(SDO_GEOMETRY(2001, 81989, SDO_POINT_TYPE(367597, 80975, NULL), NULL, NULL), 8307) fr
    om dual;
    
    SDO_CS.TRANSFORM(SDO_GEOMETRY(2001,81989,SDO_POINT_TYPE(367597,80975,NULL),NULL,
    --------------------------------------------------------------------------------
    SDO_GEOMETRY(2001, 8307, SDO_POINT_TYPE(-2.4595026, 50.6275011, NULL), NULL, NUL
    L)
    

    It works for you?

  • Unflattening table FXP gives incorrect results

    Hello

    I am trying to send data from my RIO to PC via Ethernet.

    To do this, I'm flattening of data (a table of numbers FXP) string on the RIO.

    On the PC, I'm unflattening data, but get different results.

    No idea what is the problem?

    Attached files:

    Voltages.VI - code PC

    DMARead - code on RIO.

    Thanks in advance!

    Kyle

    Hi Kyle,.

    Thank you for your post and welcome to the forums of NOR.

    The first suggestion I'd make is, data FXP you go around, you made sure the lengths of words and whole numbers are the same on both sides? If they are different, you expect the data to be different.

    Thank you

  • bad result of 10g using sys_connect_by_path, COUNT (*) OVER (PARTITION OF...)

    Hello

    I get incorrect results when I run my SQL on Oracle 10.2.0.4 prod database.
    When I run the same SQL on Oracle 11.2.0.1 prod database, I get the results I expect.

    See the PATH_TO_EMP_ROOT column in 10g (all are null, why?)

    Here's the SQLs and respective results on Oracle 10.2.0.4 prod database:
    create table TEST_WITH_EMP_TABLE
    (
      EMP_ID NUMBER(5) NOT NULL,
      EMP_NAME VARCHAR2(100) NOT NULL,
      MGR_EMP_ID NUMBER(5),
      CONSTRAINT TEST_WITH_EMP_TABLE_PK
          PRIMARY KEY (EMP_ID) USING INDEX,
       CONSTRAINT TEST_WITH_EMP_TABLE_FK1
          FOREIGN KEY (MGR_EMP_ID)
          REFERENCES TEST_WITH_EMP_TABLE(EMP_ID) ON DELETE CASCADE
    );
    
    INSERT INTO TEST_WITH_EMP_TABLE  VALUES (10, 'Emp1', null);
    INSERT INTO TEST_WITH_EMP_TABLE  VALUES (20, 'Emp2', 10);
    INSERT INTO TEST_WITH_EMP_TABLE  VALUES (30, 'Emp3', 20);
    INSERT INTO TEST_WITH_EMP_TABLE  VALUES (40, 'Emp4', 30);
    INSERT INTO TEST_WITH_EMP_TABLE  VALUES (50, 'Emp5', 10);
    INSERT INTO TEST_WITH_EMP_TABLE  VALUES (60, 'Emp6', 50);
    INSERT INTO TEST_WITH_EMP_TABLE  VALUES (70, 'Emp7', 10);
    INSERT INTO TEST_WITH_EMP_TABLE  VALUES (80, 'Emp8', null);
    commit;
    
    select level as EMP_LEVEL, 
           sys_connect_by_path(EMP_ID, '/') as PATH_TO_EMP_ROOT, 
           COUNT(*) OVER (PARTITION BY level, MGR_EMP_ID) as EMPS_COUNT,
           EMP_ID, EMP_NAME, MGR_EMP_ID
    from TEST_WITH_EMP_TABLE
    START WITH MGR_EMP_ID IS NULL
    CONNECT BY NOCYCLE PRIOR  EMP_ID = MGR_EMP_ID
    ORDER BY EMP_LEVEL, MGR_EMP_ID;
    
    EMP_LEVEL   PATH_TO_EMP_ROOT    EMPS_COUNT  EMP_ID  EMP_NAME    MGR_EMP_ID
    ---------   ----------------    ----------  ------  --------    -----------
    1           (null)              2           10      Emp1        (null)
    1           (null)              2           80      Emp8        (null)
    2           (null)              3           20      Emp2        10
    2           (null)              3           50      Emp5        10
    2           (null)              3           70      Emp7        10
    3           (null)              1           30      Emp3        20
    3           (null)              1           60      Emp6        50
    4           (null)              1           40      Emp4        30
    Exact same SQL running on * 11.2.0.1 Oracle database * as a result of results (than I expected on 10.2 as well):
    EMP_LEVEL   PATH_TO_EMP_ROOT    EMPS_COUNT  EMP_ID  EMP_NAME    MGR_EMP_ID
    ---------   ----------------    ----------  ------  --------    -----------
    1           /10                 2           10      Emp1        (null)
    1           /80                 2           80      Emp8        (null)
    2           /10/20              3           20      Emp2        10
    2           /10/50              3           50      Emp5        10
    2           /10/70              3           70      Emp7        10
    3           /10/20/30           1           30      Emp3        20
    3           /10/50/60           1           60      Emp6        50
    4           /10/20/30/40        1           40      Emp4        30
    Y at - it a bug known RDBMS? Any change that I can do to get this working on 10.2, SQL database as well?

    The other strange thing is that if I remove the
    COUNT(*) OVER (PARTITION BY level, MGR_EMP_ID) as EMPS_COUNT
    the select part of SQL on 10.2.0.4 DB column, the
     PATH_TO_EMP_ROOT 
    I get now is correct even on the 10.2 database.

    Kind regards
    Vivek.
    select level as EMP_LEVEL,
           sys_connect_by_path(emp_id, '/') as path_to_emp_root,
           --COUNT(*) OVER (PARTITION BY MGR_EMP_ID) as EMPS_COUNT,
           EMPS_COUNT,
           emp_id, emp_name, mgr_emp_id
    from (select emp_id, emp_name, mgr_emp_id,
          count(*) over (partition by mgr_emp_id) as emps_count
          from TEST_WITH_EMP_TABLE)
    start with mgr_emp_id is null
    connect by nocycle prior   emp_id=mgr_emp_id
    ORDER BY EMP_LEVEL, MGR_EMP_ID;
    
  • Text index CONTEXT Oracle which gives bad results!

    Expert Oracle Text,

    I'm on Oracle 11.2.0.2 on Solaris 10 and have implemented the Oracle text features using the CONTEXT index type, and I'm getting a few problems in. I have a need for research with joker as % and giving the wrong exit. Here's the scenario where I get incorrect results:
     
    
    --creating preferences etc 
    exec   ctxsys.ctx_ddl.create_preference ('cust_lexer', 'BASIC_LEXER'); 
    exec   ctxsys.ctx_ddl.set_attribute ('cust_lexer', 'base_letter', 'YES'); -- removes diacritics 
    exec   ctxsys.ctx_ddl.create_preference ('cust_wl', 'BASIC_WORDLIST') 
    exec   ctxsys.ctx_ddl.set_attribute ;    ('cust_wl', 'SUBSTRING_INDEX', 'true'); 
    
    --table set up 
    CREATE TABLE TEST_USER 
    ( 
      FULL_NAME  VARCHAR2(64 CHAR)                  NOT NULL, 
      LAST_NAME  VARCHAR2(64 CHAR)                  NOT NULL 
    ); 
    
    
    CREATE INDEX TEST_USER_IDX5 ON TEST_USER 
    (FULL_NAME) 
    INDEXTYPE IS CTXSYS.CONTEXT 
    PARAMETERS('LEXER cust_lexer WORDLIST cust_wl SYNC (ON COMMIT)'); 
    
    --data set up 
    Insert into TEST_USER 
       (FULL_NAME, LAST_NAME) 
    Values 
       ('Supervisor upervisor', 'upervisor'); 
    Insert into TEST_USER 
       (FULL_NAME, LAST_NAME) 
    Values 
       ('JOSEPH WILSON', 'WILSON'); 
    Insert into TEST_USER 
       (FULL_NAME, LAST_NAME) 
    Values 
       ('CHRISTOPHER Phil', 'TAYLOR'); 
    Insert into TEST_USER 
       (FULL_NAME, LAST_NAME) 
    Values 
       ('PAUL HERNANDEZ', 'HERNANDEZ'); 
    Insert into TEST_USER 
       (FULL_NAME, LAST_NAME) 
    Values 
       ('Betty Jipes', 'Jones'); 
    Insert into TEST_USER 
       (FULL_NAME, LAST_NAME) 
    Values 
       ('One Anna', 'Anna'); 
    Insert into TEST_USER 
       (FULL_NAME, LAST_NAME) 
    Values 
       ('Three Anna', 'Anna'); 
    Insert into TEST_USER 
       (FULL_NAME, LAST_NAME) 
    Values 
       ('Two Anna', 'Anna'); 
    Insert into TEST_USER 
       (FULL_NAME, LAST_NAME) 
    Values 
       ('Four Anna', 'Anna'); 
    Insert into TEST_USER 
       (FULL_NAME, LAST_NAME) 
    Values 
       ('Gary Barrow', 'Barrow'); 
    COMMIT; 
    
    --query using CONTAINS which gives WRONG output - because out intention is to return only those strings that START WITH the letter P but it returns another string that has P not at the starting!! 
    
    SQL> select full_name from test_user where contains(full_name,'P%')>0; 
    
    FULL_NAME 
    ---------------------------------------------------------------- 
    PAUL HERNANDEZ 
    CHRISTOPHER Phil 
    
    -- I need output as follows in which the second value is not returned...meaning 'CHRISTOPHER Phil' should NOT be returned by the CONTAINS clause just as the LIKE operator below doesn't return it. 
    SQL> select full_name from test_user where full_name like 'P%'; 
    
    FULL_NAME 
    ---------------------------------------------------------------- 
    PAUL HERNANDEZ 
    Please can anyone suggest what to do about it?

    Thank you
    OrauserN

    No, you can skip all those, if you use SUBSTRING_INDEX.

  • Please explain CVI question #335358: using the operator of bit-shift twice on the same line of code produces incorrect results

    Hello

    I just stumbled on http://www.ni.com/white-paper/12323/en#335358_by_Category.

    With the help of the bit-shift operator twice on the same line of code produces incorrect results.
    Workaround: Separate the operations of shift of two bits in two distinct lines of code.

    Reported Version: 9.0    Solved Version: N/A    Added the: 14/02/2012

    Could someone please explain what kind of construction causes such a question?

    I have not noticed problems again and not have not noticed or found a thread about it.

    Thank you.

    The reported scenario looks like this:

    unsigned int a = 1, b = 62;
    unsigned  long long result = 1ULL << a << b;
    

    The problem arises because of the temporary variable used when do two little is placed in the same line. This separation into two lines will produce correct results:

    unsigned int a = 1, b = 62;
    unsigned  long long result = 1ULL << a;
    result = result << b;
    
  • overall index using partitioning of the interval.

    Can we have an index that is partitioned across the world using range partitioning on the number field in the database table.

    >
    Can we have an index that is partitioned across the world using range partitioning on the number field in the database table.
    >
    No - a global index cannot be paritioned of the interval.
    You can create a range partitioned or Hash-Partitioned Global index, but it cannot use partitioning interval. The index may be on a table is partitioned apart, but the index itself cannot be partitioned apart.

    See Creation of Partitions in the VLDB and partitioning Guide database
    http://docs.Oracle.com/CD/E18283_01/server.112/e16541/part_admin001.htm#i1006455

    and the CREATE INDEX SQL language doc section
    http://docs.Oracle.com/CD/E11882_01/server.112/e26088/statements_5012.htm#i2062403

  • Use of indexes is not recorded in v$ object_usage...

    Hi all

    A few days ago, I posted a question to see if table scans / index deemed "used" index followed its use.

    Now I have a bit of the opposite question: I can't seem to get clues to "confess" v$ object_usage they been used!

    I tried this on two systems: a quarter-rack race Exadata V1 11.2.0.2 BP7 and a 11.2.0.3 (vanilla) running on AIX 5.3

    I can't make it work on either, despite the fact that I have activated it for 900 non-unique index on the Exadata machine and 300 on the AIX 5.3 database. The two are producing, so I expect high activity levels.

    That's what I did. Maybe I did something wrong. Surely that I did.

    The control of its use on the index WE - I did yesterday
    ALTER INDEX schema1.decentsizedtab_nu-idx1 MONITORING USAGE;
    Find the name of owner or table on which the index is based. When I run the present, nothing crazy is returned. It is a unique, valid, index that has not been analyzed since June 2010. It is NOT partitioned, NOT temporary and NOT invisible. Segments were created for the index.
    SELECT owner, index_name, index_type, table_owner, table_name, table_type, uniqueness, status, last_analyzed, partitioned, temporary, global_stats, visibility, segment_created
    FROM dba_indexes
    WHERE owner = 'SCHEMA1'
    AND index_name = 'DECENTSIZEDTAB_NU-IDX1';
    Determine the columns in dba_ind_columns
    SELECT index_owner, index_name, column_name, column_position
    FROM dba_ind_columns
    WHERE index_owner = 'SCHEMA1'
    AND index_name = 'DECENTSIZEDTAB_NU-IDX1';
    
    SCHEMA1 DECENTSIZEDTAB_NU-IDX1  COL_1               1
    SCHEMA1 DECENTSIZEDTAB_NU-IDX1  COL_2               2
    SCHEMA1 DECENTSIZEDTAB_NU-IDX1  COL_3               3
    SCHEMA1 DECENTSIZEDTAB_NU-IDX1  COL_4               4
    So you would think that would use the index, especially if I give this move a bit to use it...
    EXPLAIN PLAN FOR
    SELECT /*+ INDEX (schema1.decentsizedtab_nu-idx1)*/ col_1, col_2, col_3, col_4
    FROM schema1.decentsizedtab;
    The plan of the explain command shows that we use the DECENTSIZEDTAB_NU-IDX1 index.
    SELECT * FROM table(DBMS_XPLAN.DISPLAY);
    
    Plan hash value: 1798057294
    --------------------------------------------------------------------------------------------
    | Id  | Operation                    | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
    --------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT             |             |   145K|  2138K|    97   (2)| 00:00:02 |
    |   1 |  INDEX STORAGE FAST FULL SCAN| DECENTSIZEDTAB_NU-IDX1|   145K|  2138K|    97   (2)| 00:00:02 |
    --------------------------------------------------------------------------------------------
    OK, so we're going to execute the statement and see if the index is used...
    SELECT /*+ INDEX (schema1.decentsizedtab_nu-idx1)*/ col_1, col_2, col_3, col_4
    FROM schema1.decentsizedtab;
    
         145721 rows selected.
    Once this is completed, we will check the object_usage view $ v to see if it has registered using the index
    SELECT * 
    FROM v$object_usage;
    
    No rows returned.
    LOL. Nope. Bitch index tracking! *

    I have not considered the fact that exadata was involved (unloading, etc.) to perform this operation somehow, but as I said, I tried this with an Oracle database restart a single instance and I see the same thing.

    Thoughts? Ideas? Critical? Personal insults?

    Mark

    marksmithusa wrote:
    I noticed that MOS Note 261756.1 gives to think you have to be connected to the schema owner to display the results.

    It is a real pain because I have 50-60 patterns in the Exadata database AND I am logged in as SYSDBA - surely, I should be able to see everything in v$ object_usage?

    Here is the definition of v$ object_usage

    select io.name, t.name,
           decode(bitand(i.flags, 65536), 0, 'NO', 'YES'),
           decode(bitand(ou.flags, 1), 0, 'NO', 'YES'),
           ou.start_monitoring,
           ou.end_monitoring
    from sys.obj$ io, sys.obj$ t, sys.ind$ i, sys.object_usage ou
    where io.owner# = userenv('SCHEMAID')
      and i.obj# = ou.obj#
      and io.obj# = ou.obj#
      and t.obj# = i.bo#
    

    The predicate: io.owner # = userenv ('SCHEMAID') is that which limits the output to the current user.
    If you can connect with a login adapted, you could create another view that eliminates this predicate, perhaps adding to the selection in the io.owner list #, or even join user$ on io.owner # u.user = #, for example

    select u.name, io.name, t.name,
           decode(bitand(i.flags, 65536), 0, 'NO', 'YES'),
           decode(bitand(ou.flags, 1), 0, 'NO', 'YES'),
           ou.start_monitoring,
           ou.end_monitoring
    from sys.obj$ io, sys.obj$ t, sys.ind$ i, sys.object_usage ou, sys.user$ u
    where i.obj# = ou.obj#
      and io.obj# = ou.obj#
      and t.obj# = i.bo#
      and u.user# =  io.owner#
    ;
    

    Concerning
    Jonathan Lewis

  • Help for Oracle to use an index

    Unfortunately, I'm stuck with Oracle 8i. I have a fairly complex view which, at the time of the call, will have values specified for the columns in the view.

    The full view will look something like this - even if real life tables are slightly different and a little more complex. (view has been developed [another post | http://forums.oracle.com/forums/thread.jspa?threadID=1043162 & messageID = 4163818 #4163818]):
    select  a.skuid,
            sum(a.qty) qty,
            a.lot,
            b.status
            status
      from  (
             select  skuid,
                     lot,
                     1 qty,
                     row_number() over(partition by skuid order by lot) rn
               from  lot,
                     (
                      select  rownum rnum
                        from  all_objects
                        where rownum <= (select sum(qty) from lot)
                     )
               where rnum <= qty
            ) a,
            (
             select  skuid,
                     status,
                     sum(qty) over(order by qty desc) - qty + 1 start_rn,
                     sum(qty) over(order by qty desc) end_rn
               from  status
            ) b
      where b.skuid = a.skuid
        and a.rn between b.start_rn and end_rn
      group by  a.skuid,
                b.status,
                a.lot
      order by  a.skuid,
                b.status,
                a.lot
    When this view is called, there will certainly skuid and skuid is indexed. The problem I'm having becomes Oracle to bring the skuid specified in the Interior selects.

    For now, concentrate on the online portion "a":
     select  skuid,
          lot,
          1 qty,
          row_number() over(partition by skuid order by lot) rn
       from  lot,
          (
           select  rownum rnum
             from  row_gen
          )
       where rnum <= qty
    If I put this part of the display within a select statement as follows:
    select skuid, lot, sum(qty) from
    (
     select  skuid,
          lot,
          1 qty,
          row_number() over(partition by skuid order by lot) rn
       from  lot,
          (
           select  rownum rnum
             from  row_gen
             where rownum <= (select max(qty) from lot)
          )
       where rnum <= qty
       AND SKUID = 'SKUA' -- <--- Note indexed column here
    )
    group by skuid, lot
    Can I get a good result of query performance. Similar to this execution plan:
    Execution Plan
    ----------------------------------------------------------
       0      SELECT STATEMENT Optimizer=RULE
       1    0   SORT (GROUP BY)
       2    1     VIEW
       3    2       WINDOW (SORT)
       4    3         COUNT
       5    4           NESTED LOOPS
       6    5             VIEW
       7    6               COUNT (STOPKEY)
       8    7                 TABLE ACCESS (FULL) OF 'ROW_GEN'
       9    5             TABLE ACCESS (BY INDEX ROWID) OF 'LOT'
      10    9               INDEX (RANGE SCAN) OF 'LOT_SKU' (UNIQUE)
    However, when I move the indexed column outside the Interior view (where it will be in real life), like this:
    select skuid, lot, sum(qty) from
    (
     select  skuid,
          lot,
          1 qty,
          row_number() over(partition by skuid order by lot) rn
       from  lot,
          (
           select  rownum rnum
             from  row_gen
             where rownum <= (select max(qty) from lot)
          )
       where rnum <= qty
    )
    WHERE SKUID = 'SKUA' -- <--- Note indexed column here, 
                         --      since inner view will be an Oracle view, not inline view
    group by skuid, lot
    So in this case, the performance is very poor, with a similar to this execution plan:
    Execution Plan
    ----------------------------------------------------------
       0      SELECT STATEMENT Optimizer=RULE
       1    0   SORT (GROUP BY)
       2    1     VIEW
       3    2       WINDOW (SORT)
       4    3         COUNT
       5    4           NESTED LOOPS
       6    5             VIEW
       7    6               COUNT (STOPKEY)
       8    7                 TABLE ACCESS (FULL) OF 'ROW_GEN'
       9    5             TABLE ACCESS (FULL) OF 'LOT'
    In the example of real life, the unique key is actually 5 columns, but the principle, I think, it's the same.

    So, is it possible to write this request (which will be a view) such as Oracle (8i) realizes he can carry the values specified in the Interior selects and use the index for them?

    Published by: kent b on March 16, 2010 08:29

    Adding a / * + INDEX() * / index in the Interior, select help a little, but is still nowhere near as fast when the skuid is specified in the internal selection.

    Hello

    Here is another solution to this problem that uses any CONNECT BY and does not assume that this amount represents an integer.

    In your previous thread
    Re: Very challenging FINDS to write (call for help)
    Solomon has shown how we can avoid "explode" status in units, using a total cumulative.
    The solution below does the same thing for many, as well.

    SELECT       l.skuid
    ,            LEAST (l.max_qty, s.max_qty)
           - GREATEST (l.min_qty, s.min_qty)     AS qty
    ,       l.lot
    ,       s.status
    FROM       (     -- Begin in-line view l to get data from lot
                SELECT      skuid
              ,      lot
              ,      SUM (qty) OVER ( PARTITION BY  skuid
                                       ORDER BY       SUBSTR (lot, 1, 1)
                               ,          TO_NUMBER (SUBSTR (lot, 2))
                             )  - qty     AS min_qty
              ,      SUM (qty) OVER ( PARTITION BY  skuid
                                       ORDER BY       SUBSTR (lot, 1, 1)
                               ,          TO_NUMBER (SUBSTR (lot, 2))
                             )           AS max_qty
              FROM     lot
           ) l     -- End in-line view l to get data from lot
    ,       (      -- Begin in-line view s to get data from status
                SELECT      skuid
              ,      status
              ,      SUM (qty) OVER ( PARTITION BY  skuid
                                                 ORDER BY       CASE
                                            WHEN  status = 'AVAIL'  THEN  1
                                            WHEN  status = 'RES'     THEN  2
                                            WHEN  status = 'HOLD'     THEN  3
                                               END
                                 ) - qty     AS min_qty
              ,      SUM (qty) OVER ( PARTITION BY  skuid
                                                 ORDER BY       CASE
                                            WHEN  status = 'AVAIL'  THEN  1
                                            WHEN  status = 'RES'     THEN  2
                                            WHEN  status = 'HOLD'     THEN  3
                                               END
                                 )           AS max_qty
              FROM     status
           ) s     -- End in-line view s to get data from status
    WHERE       l.skuid      = s.skuid
    AND       l.min_qty    < s.max_qty
    AND       s.min_qty    < l.max_qty
    ORDER BY  l.skuid
    ,            l.max_qty
    ,       s.max_qty
    ;
    

    Published by: Frank Kulash, March 16, 2010 13:23

    It might be easier to manage if we pull the min_qty of the max_qty, like this:

    SELECT       l.skuid
    ,            LEAST (l.max_qty, s.max_qty)
           - GREATEST (l.min_qty, s.min_qty)     AS qty
    ,       l.lot
    ,       s.status
    FROM       (     -- Begin in-line view l to get data from lot
                SELECT      skuid,      lot
              ,      max_qty
              ,      max_qty - qty     AS min_qty
              FROM      (      -- Begin in-line view to get max_qty
                          SELECT      skuid,      lot,  qty
                         ,      SUM (qty) OVER ( PARTITION BY  skuid
                                                         ORDER BY       SUBSTR (lot, 1, 1)
                                           ,          TO_NUMBER (SUBSTR (lot, 2))
                                         )  AS max_qty
              FROM     lot
                    )      -- End in-line view to get max_qty
           ) l     -- End in-line view l to get data from lot
    ,       (      -- Begin in-line view s to get data from status
                SELECT      skuid,      status
              ,      max_qty
              ,      max_qty - qty     AS min_qty
              FROM      (      -- Begin in-line view to get max_qty
                          SELECT  skuid,  status,  qty
                         ,      SUM (qty) OVER ( PARTITION BY  skuid
                                                                  ORDER BY       CASE
                                                      WHEN  status = 'AVAIL'  THEN  1
                                                      WHEN  status = 'RES'     THEN  2
                                                      WHEN  status = 'HOLD'     THEN  3
                                                         END
                                           )  AS max_qty
              FROM     status
                    )      -- End in-line view to get max_qty
           ) s     -- End in-line view s to get data from status
    WHERE       l.skuid      = s.skuid
    AND       l.min_qty    < s.max_qty
    AND       s.min_qty    < l.max_qty
    ORDER BY  l.skuid
    ,            l.max_qty
    ,       s.max_qty
    ;
    
  • Indicator string displays incorrect results

    Hello, I have a duty, and I am facing some problems with string indicator.

    What I am assigned is:

    The user fills 2 bays with 5 numbers

    E FILL button is clicked, and then the program checks if the items created in table 3 matches elements in table 1 and 2.

    (I have attached the file doc for clarity).

    Channel indicator sometimes give the wrong answers. (is there a better way to solve the channel indicator?)

    Thank you.

    the vi is version 10.

    Better is how? Do not place the extra empty lines in the string? If this is the case you only need to update the chain when necessary, not every iteration of the loop. If you mean something else I don't know what you want to improve.

    There are many things that can be improved from a coding perspective. When you wire up a table in a loop, it is preferable to use automatic indexing to determine the number of iterations of the loop will run. Except that as in the case of your first loop, you must use table size to determine the number of iterations to run, not a constant value. Your second loop can be simplified and does not require the table. Use a shift register and reduce to zero the value of the Boolean value each iteration. In addition, the logic in the context of the third would be easier to understand if you used one or rather than an and. If any value is True check tables. Your actually have the reverse logic. If it is true, it is the opposite of what someone might think. Another method would be to add the two results and wire numberic value to the structure of the case. Case '0' means that everything is acceptable. If default (anything not 0) means you have unacceptable values.

    A final comment would be what is actually your stop condition? The two nested while loops seems rather strange and unnecessary.

  • SDO_NN cannot be assessed without using the index when put inside subquery

    Hi all

    I met a problem when you use the function sdo_nn to find the nearest neighbor. Here is my scenario:

    _ I have 2 customer and store tables.

    Customer table _ a client_ID and a 2D sdo_geom point

    _ Store table has store_ID and a 2D polygon sdo_geom.

    In the beginning, I have this query to find the nearest store to each customer as below:

    Select s.STORE_ID, c.CLIENT_ID

    store customer, s c

    where sdo_nn (s.MYPOLYGON, c.MYPOINT, 'sdo_num_res = 1', 1) = "TRUE";

    _It works as expected when it returns a table showing the nearest store each customer.

    _Now I want to count the number of customers who have the same nearest store:

    Select / * + INDEX (store store_spatial_idx, client_spatial_idx client) * / count (nearest_store. CLIENT_ID)
    from (select s.STORE_ID, c.CLIENT_ID
    store customer, s c
    where sdo_nn (s.MYPOLYGON, c.MYPOINT, 'sdo_num_res = 1', 1) = "TRUE") nearest_store
    Group of nearest_store. STORE_ID;

    This query generates the following error:

    Error report-
    SQL error: ORA-13249: SDO_NN cannot be assessed without using the index
    ORA-06512: at the 'MDSYS. MD", line 1723
    ORA-06512: at the 'MDSYS. MDERR", line 17
    ORA-06512: at the 'MDSYS. PRVT_IDX', line 9
    13249 00000 - '%s '.

    I'm pretty new to spatial databases and hope get help to go further. Thank you in advance!

    Hello Pinball,

    Oracle space tends to be a quite complex with many variables and moving parts.  We chatted about the group to a sort of FAQ or guidelines to help people like you submit questions that actually answers.  First of all, you really have to tell us the version of Oracle you are using.  Particularly the problems involving the optimizer, version down to the exact defined patch number is a good idea.  Secondly, you took the time to submit the question so I guess you want a response.  If you really want to see the answer and then providing an example is one of the most important things that you can do.  I'm going to do here for you, but in general people on this forum come and go and are often pushed into lurkitude, so if you want the coax to provide you with an example of work is the key.

    DROP TABLE store1 PURGE;
    CREATE TABLE store1(
        store_id INTEGER NOT NULL
       ,shape    MDSYS.SDO_GEOMETRY
       ,PRIMARY KEY(store_id)
    );
    
    DROP TABLE client2 PURGE;
    CREATE TABLE client2(
        client_id INTEGER NOT NULL
       ,shape    MDSYS.SDO_GEOMETRY
       ,PRIMARY KEY(client_id)
    );
    
    CREATE OR REPLACE PROCEDURE seeder(
        p_client_count IN NUMBER
       ,p_store_count IN NUMBER
    )
    AS
      sdo_foo MDSYS.SDO_GEOMETRY;
      int_counter NUMBER;
      FUNCTION random_point
      RETURN MDSYS.SDO_GEOMETRY
      AS
          num_x1 NUMBER;
          num_y1 NUMBER;
    
      BEGIN
          num_x1 := dbms_random.value(-179,179);
          num_y1 := dbms_random.value(-89,89);
    
          RETURN MDSYS.SDO_GEOMETRY(
              2001
             ,8265
             ,MDSYS.SDO_POINT_TYPE(
                  num_x1
                 ,num_y1
                 ,NULL
              )
             ,NULL
             ,NULL
          );
    
      END random_point;
    
    BEGIN
      int_counter := 1;
      FOR i IN 1 .. p_client_count
      LOOP
          -- Create a client point
          sdo_foo := random_point();
          INSERT INTO client2
          VALUES (
              int_counter
             ,sdo_foo
          );
          int_counter := int_counter + 1;
    
      END LOOP;
    
      int_counter := 1;
      FOR i IN 1 .. p_store_count
      LOOP
          -- Create a store polygon of some kind
          sdo_foo := MDSYS.SDO_GEOM.SDO_ARC_DENSIFY(
              MDSYS.SDO_GEOM.SDO_BUFFER(
                  random_point()
                 ,5000
                 ,0.05
              )
             ,0.05
             ,'arc_tolerance=0.05'
          );
          INSERT INTO store1
          VALUES (
              int_counter
             ,sdo_foo
          );
          int_counter := int_counter + 1;
    
      END LOOP;
    
      COMMIT;
    
    END seeder;
    /
    
    BEGIN
      seeder(10000,200);
    END;
    /
    
    BEGIN
      INSERT INTO user_sdo_geom_metadata(
          table_name
         ,column_name
         ,diminfo
         ,srid
      ) VALUES (
          'STORE1'
         ,'SHAPE'
         ,MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',-180,180,.05),MDSYS.SDO_DIM_ELEMENT('Y',-90,90,.05))
         ,8265
      );
    
      COMMIT;
    
    EXCEPTION
      WHEN OTHERS
      THEN
          NULL;
    
    END;
    /
    
    BEGIN
      INSERT INTO user_sdo_geom_metadata(
          table_name
         ,column_name
         ,diminfo
         ,srid
      ) VALUES (
          'CLIENT2'
         ,'SHAPE'
         ,MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',-180,180,.05),MDSYS.SDO_DIM_ELEMENT('Y',-90,90,.05))
         ,8265
      );
    
      COMMIT;
    
    EXCEPTION
      WHEN OTHERS
      THEN
         NULL;
    
    END;
    /
    
    CREATE INDEX store1_spx ON store1
    (shape)
    INDEXTYPE IS MDSYS.SPATIAL_INDEX
    NOPARALLEL;
    
    CREATE INDEX client2_spx ON client2
    (shape)
    INDEXTYPE IS MDSYS.SPATIAL_INDEX
    NOPARALLEL;
    
    /* Works as expected */
    SELECT
    s.store_id
    ,c.client_id
    ,MDSYS.SDO_NN_DISTANCE(1)
    FROM
    store1 s
    ,client2 c
    WHERE
    MDSYS.SDO_NN(
        s.shape
       ,c.shape
       ,'sdo_num_res=1'
       ,1
    ) = 'TRUE';
    
    /* No worky? Works for me */
    SELECT
    ns.store_id
    ,COUNT(ns.client_id)
    FROM (
       SELECT
        s.store_id
       ,c.client_id
       FROM
        store1 s
       ,client2 c
       WHERE
       MDSYS.SDO_NN(
           s.shape
          ,c.shape
          ,'sdo_num_res=1'
          ,1
       ) = 'TRUE'
    ) ns
    GROUP BY
    ns.store_id
    ORDER BY
    ns.store_id;
    

    So I wrote this about 12 c (12.1.0.2.0) and everything works fine for me.  Then I moved back from 11 GR 2 (11.2.0.4.0) and of course, there are questions.  So I guess that you don't use flavor of 11g.  So at this point we can look at the docs and see for 11g, have you often need to specify which table is the head and that is the one that has the spatial index to use.
    http://docs.Oracle.com/CD/E11882_01/AppDev.112/e11830/sdo_operat.htm#SPATL1032

    Its rather interesting that the optimizer of 12 c knows what you want, when I had to squint myself at your request and to play a little with the refining.  Note that SDO_NN is sensitive, because the geometry of the main table should come second in the operator.  I did not know that on the top of my head.

    
    SELECT
    /*+ LEADING(c) INDEX(s store1_spx)  */
     s.store_id
    ,c.client_id
    ,MDSYS.SDO_NN_DISTANCE(1)
    FROM
     store1 s
    ,client2 c
    WHERE
    MDSYS.SDO_NN(
        s.shape
       ,c.shape
       ,'sdo_num_res=1'
       ,1
    ) = 'TRUE';
    
    SELECT
     ns.store_id
    ,COUNT(ns.client_id)
    FROM (
       SELECT
       /*+ LEADING(c) INDEX(s store1_spx)  */
        s.store_id
       ,c.client_id
       ,MDSYS.SDO_NN_DISTANCE(1)
       FROM
        store1 s
       ,client2 c
       WHERE
       MDSYS.SDO_NN(
           s.shape
          ,c.shape
          ,'sdo_num_res=1'
          ,1
       ) = 'TRUE'
    ) ns
    GROUP BY
    ns.store_id
    ORDER BY
    ns.store_id;
    

    So I think that is your answer.  Give it a shot and see if this fits the Bill.  Of course, moving to 12 c would be useful for such things.  It would be interesting to collect more examples of this kind of space thing where 12 c is the answer. Also, would be nice if we could mark somehow this discussion as applying only to 11g and earlier versions.

    See you soon,.

    Paul

  • Incorrect results of SDO_GEOM. Relate()

    Hi all

    I get incorrect results of calls to SDO_GEOM.relate / SDO_RELATE / SDO_INSIDE etc., apparently because they cannot handle the values of Longitude both positive and negative in the same query.

    The request goes in the direction of
    SELECT COUNTRY,
     SDO_GEOM.relate(SCOTT.ASIA.GEOLOC, 'DETERMINE', < A Transient Geometry>, '0.005') from SCOTT.ASIA;
    Where SCOTT.ASIA is a layer containing a geometry for each Asian countries (although I experienced the same behavior with other, more simple polygons)
    And transitional geometry is defined:
    MDSYS.SDO_GEOMETRY(
                2003,
                8307,
                null,
                MDSYS.SDO_ELEM_INFO_ARRAY(1,1003, 1),
                MDSYS.SDO_ORDINATE_ARRAY(-1.2,   89.9,   6.6,  -16.2,  170.3,  -21.1,  168.25,  89.9,  -1.2,  89.9))
    This query gives me:
    Malaysia     DISJOINT
    Maldives     DISJOINT
    Mongolia     DISJOINT
    Myanmar     DISJOINT
    ...etc
    When all these geometries have to resolve on the INSIDE.
    I traced this issue to the fact that there is a selected point with a negative longitude (-1.2, 89.9), which should be perfectly fine. If I change of (1,2, 89.9):
    I get:
    Malaysia     INSIDE
    Maldives     INSIDE
    Mongolia     INSIDE
    Myanmar     INSIDE
    ...etc
    This occurs regardless of what point is outside the hemisphere for example:
    ...  MDSYS.SDO_ORDINATE_ARRAY(-1.2,   89.9,   6.6,  -16.2,  170.3,  -21.1,  168.25,  89.9,  -1.2,  89.9)...
    ...  MDSYS.SDO_ORDINATE_ARRAY(1.2,   89.9,   6.6,  -16.2,  170.3,  -21.1,  *191.75*,  89.9,  1.2,  89.9)...
    ...  MDSYS.SDO_ORDINATE_ARRAY(1.2,   89.9,   6.6,  -16.2,  170.3,  -21.1,  *-168.25*,  89.9,  1.2,  89.9)...
    Note that the second and third entries represent a limit to the East that surrounds the Western hemisphere. None of these definitions provide good results when using SDO_GEOM.relate

    Is there a way to make sure that spatial queries returning correct results with geometries that envelop this way?

    Thank you

    This type of query "whole earth" does not work as you did. See http://download.oracle.com/docs/html/B14255_01/sdo_cs_concepts.htm#i891851
    >
    The following size limits apply, with geodetic data
    No polygon element can have an area larger than half of the surface of the Earth.
    Online, the distance between two adjacent coordinates cannot be greater or equal to half of the perimeter (a great circle) of the Earth.

    If you need to work with larger items, first break these elements into several smaller components and work with them. For example, you cannot create a geometry that represents the entire surface of the Earth; However, you can create several geometries, each representative of the global ocean surface. To work with a line string that is greater than or equal to half of the perimeter of the land, you can add one or more points on the line so that all adjacent coordinates are less than half of the perimeter of the land.
    >

    Search this forum for "Earth." for example
    Re: Simple Transformation work not as expected
    the whole earth MBR GEODESIC

  • Satellite L10 and keyboard:-shift key gives wrong results

    Using the SHIFT key with most of other than a-z keys gives bad result.
    I tried to re - install a driver via Control Panel / keyboard with the Toshiba XP Home CD inserted but not better driver is found.
    Control Panel / regional and language setting is English UK

    Hello, Alan

    It will be nice if you can give us more information. What specific keyboard of the country you have? What you want to do exactly? Give us a few examples please.

  • I use Windows 7 Professional, my result the research failed to complete folder list. Help, please!

    I use Windows 7 Professional, my result the research failed to complete folder list. Help, please!

    Hi Shaji,

    You are referring to the methods mentioned links.

    Method 1: Fix Windows Desktop Search when it hangs or no display of results

    http://support.Microsoft.com/mats/windows_search?WA=wsignin1.0

    Method 2:

    Open the troubleshooter for search and indexing

    http://Windows.Microsoft.com/en-us/Windows7/open-the-search-and-indexing-Troubleshooter

    For your reference:

    Change advanced indexing options

    http://Windows.Microsoft.com/en-us/Windows7/change-advanced-indexing-options

    Improve Windows searches using the index: frequently asked questions

    http://Windows.Microsoft.com/en-us/Windows7/improve-Windows-searches-using-the-index-frequently-asked-questions

    Hope this information helped!

  • OBIEE 11 g: get incorrect results when you browse detailed report summary.

    Hello

    I get incorrect results when you browse detailed report summary.

    Please find the attached document, I have gives step by step with screen shots.

    Please let me the problem and the solution.

    Kind regards

    Srinivas.

    1. What are you going through the link of action, only pass you the values (between 61 and 65) and Total, are

    If so that the parameter value will not restrict your report in detail, try filterout gender and age (between 61 and 65) group through action link.

    2 Total, to filter only the sex,

    Concerning

    Rajagopal.

Maybe you are looking for

  • Do not INSTALL Microsoft XP Professional updates

    Download updates. They fail to install last month. No changes on the computer. I get the following message:problem: a problem on your computer is preventing updates to be downloaded or installed. Microsoft Windows XP, Microsoft Office 2003, Microsoft

  • XP Professional Taskbar stuck in Classic Mode

    The taskbar repair tool Plus can work for some things, but it does NOT fix a stuck in classic mode - XP taskbar, and I even paid the $5.00 to open this repair option.I'm betting it has something to do with an entry somewhere - but where registry and

  • Is it possible to put someone in multiple passwords before having to connect

    Is it possible to ensure that the user put in several passwords must be able to connect, like lets say, you have a password you type correct i8n and then you have a prompt for a second password? That's all before access to the desktop of your compute

  • I get calls at home.

    They claim that they are Microsoft/windows and I have a virus/malware appear on my system. I got about 3 or 4 calls (the first when the India had the blackout the appellant had an Indian accent). I not had problems with my computer at home, they say

  • Surface of synchronization manually to the MDM Server

    How manually synchronize us the Windows RT device with MDM server.