Returns the rows of a range of numbers

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0

Hello

Suppose we have a table that contains 2 columns, one is the beginning of range a second the end of it:
with t1 as 
 (select 100 start_r, 250 end_r, 'R1' range_type from dual
  union all
  select 300 start_r, 350 end_r, 'R2' range_type from dual)
select * from t1
Is it possible to get an output like:
CNUMBER    RANGE_TYPE
100          R1
101          R1
102          R1
.....
250          R1
300          R2
.....
350          R2
Thank you very much, Alex.
WITH t1 AS
     (SELECT 100 start_r, 250 end_r, 'R1' range_type
        FROM DUAL
      UNION ALL
      SELECT 300 start_r, 350 end_r, 'R2' range_type
        FROM DUAL)
SELECT *
  FROM t1,
       (SELECT     LEVEL lvl
              FROM dual
        CONNECT BY LEVEL <= (SELECT MAX (end_r) mx
                               FROM t1)) t2
where t2.lvl between t1.start_r and t1.end_r 

Tags: Database

Similar Questions

  • To return the rows less value and the next line of the value 'hungry '.

    I'm about 10 gr 2

    My best here trying to just do a single SQL rather than writing PL/SQL. I know it's possible, that I'm not good at SQL past oracle 8i. I have searched the forums and found many examples for the beaches and dates to help connect by level, but nothing specifically related to the scales of value.

    Basically I have a table with the number of employees and approval limits:
      with  a as (select 12345 emp_no,1000 val from dual 
                     UNION select 12346,5000 from dual UNION select 12347,9999 from dual)
      select * from a 
    Returns
    EMP_NO  VAL
    ------- ---------------
    12345   1000
    12346   5000
    12347   9999
    I want a SQL statement that returns all lines less that the & parameter, but also the line of 'the child' who, as "greater" as the largest value of the value to be less than the value parameter.

    It is probably easier to show examples.

    If & parameter was broadcast then 2342
    EMP_NO  VAL
    ------- ---------------
    12345   1000
    12346   5000
    If & parameter was broadcast then 7898
    EMP_NO  VAL
    ------- ---------------
    12345   1000
    12346   5000
    12347   9999
    If & parameter was broadcast then 10
    EMP_NO  VAL
    ------- ---------------
    12345   1000
    If & parameter was broadcast and 788777
    No rows returned 
    Basically, I'm trying to return the chain of trust that a Bill will have to cross before it can be approved until the & amount of parameter.

    Tried to connect, even lead function. Request for assistance from the gurus to do things. Hope that this could also help others.

    Published by: user13007502 on February 8, 2012 04:56

    Published by: user13007502 on February 8, 2012 04:58

    Hello

    Here's a way (very similar to what Peter posted previously):

    SELECT     *
    FROM     a
    WHERE     val     <= (
                   SELECT  MIN (val)
                   FROM     a
                   WHERE     val > 3000     -- or whatever
                 )
    ;
    

    If the parameter is greater than any what val in the table, then the scalar subquery terturn will be NULL, and the WHERE clause will never real.

  • To return the rows

    Dear members
    I need a function to return the lines

    This is my sample data
    ID     DESC               UNI          CODE
    1     BO_USER               40352          A
    2     BO_USER1          40353          D
    3     BUSINESS_PARTNER1     40353          F
    4     BUSINESS_PARTNER2     40354          R
    5     BUSINESS_PARTNER3     40354          N
    If I pass the id and United as an input value, that I need to get all of the line as well

    Create or replace function ((ID en varchar2, UNI en varchar2))
    return
    l_val;


    Itry to serve table tpe
    and the type as object and call that function, but when I try to call this value, I am not able to
    use of the name of the function instead of this I need to use
    slect * form the name of the table function

    If somene post a few syntax how to I will follow

    regads

    Hello

    You can create the function with the return type as table % rowtype. And even you can call this function in a block anonymous plsql and display the desired value.
    But in sqlplus, you won't be able to use it as a sql statement since it is the unsupported data type.

    This was based on my understanding of the declared scénarion. Let us know if its different

    SBH

  • To return the rows when there is a certain difference between dates

    Hello.

    I have a table called

    #president #.
    pres_name
    BIRTH_DATE

    and

    #winner #.
    name
    year_elected

    I wish I had all the presidents returned, who where under the age of 50 years when they elected.
    year_elected is only a 4-digit number; 1924 etc. While birth_date is 2001-01-01 etc.

    I have no idea how to make this work, ive tried substr and one things and a lot of other weird (prob wrong).
    select distinct p.pres_name, substr(p.birth_date, 0, 4), w.year_elected
    from president p, winner w
    where p.pres_name = w.name
    I did this witch query will show me all the presidents and their dates for the election and the date of birth. Now I just want something that returns only the guys where there is a difference in value 49 (?) between birth_date and year_elected


    Johan

    Edited by: user10248089 02-Oct-2008 00:42

    Based on information from Dave on presidents being elected the first Tuesday of November...

    SQL> with president as (select 'Bob' as pres_name, to_date('1/7/1934','DD/MM/YYYY') as birth_date from dual union all
      2                     select 'Fred', to_date('13/5/1950','DD/MM/YYYY') from dual union all
      3                     select 'Jim', to_date('21/12/1960','DD/MM/YYYY') from dual)
      4      ,winner    as (select 'Bob' as name, '1979' as year_elected from dual union all
      5                     select 'Fred', '2005' from dual union all
      6                     select 'Jim', '2000' from dual)
      7  --
      8  select p.pres_name, p.birth_date, w.year_elected
      9        ,trunc(months_between(next_day(to_date('01/11/'||w.year_elected,'DD/MM/YYYY'),'TUE'),birth_date)/12) as age
     10  from president p join winner w on (p.pres_name = w.name)
     11  /
    
    PRES BIRTH_DAT YEAR        AGE
    ---- --------- ---- ----------
    Bob  01-JUL-34 1979         45
    Fred 13-MAY-50 2005         55
    Jim  21-DEC-60 2000         39
    
    SQL>
    

    And the WHERE clause can be applied based on the same calculation as described in the age column

  • In the case of a range of numbers

    I don't know that it's really simple. but I can't find the words to search for find my answer.

    Series w for '19 '.

    If w is then {1 thru w}

    display the dialog box "on the beach!

    end if

    Thank you very much

    Matt

    I still did ' t ask the right question.

    define a '15 '.

    Series w for '19 '.

    If w is then {1 thru w}

    display the dialog box "on the beach!

    end if

    Opted for a work around.

    If ≥ 1 and an and aw ≤

    Display dialog box "In the beach!

    end if

  • Returns the rows of the stored procedure - my 1st attempt

    Hello world

    The following code compiles with the error ' Error (11.1): PLS-00103: encountered the symbol "/" '. '.

    In this example, I use SYSDATE to simplicity. The actual procedure will do much more.

    Thanks in advance for your help,

    Lou

    create or replace
    PACKAGE pkg_Search
    AS

    TYPE CUSTOM_REF_CURSOR IS REF CURSOR;

    My_Procedure PROCEDURE)
    arg_Cursor IN OUT CUSTOM_REF_CURSOR);

    END;
    -LINE 11

    CREATE or REPLACE PACKAGE pkg_Search BODY
    AS

    My_Procedure PROCEDURE)
    arg_Cursor in THE CUSTOM_REF_CURSOR)
    IS
    BEGIN

    OPEN FOR Arg_Cursor
    FROM DUAL SELECT SYSDATE;

    END;

    END;
    /

    copy the specification and body separately in SQL * Plus and you're fine

    SQL> create or replace
      2  PACKAGE pkg_Search
      3  AS
      4  TYPE CUSTOM_REF_CURSOR IS REF CURSOR;
      5  PROCEDURE My_Procedure (
      6  arg_Cursor IN OUT CUSTOM_REF_CURSOR);
      7  END;
      8  /
    
    Package created.
    
    SQL> CREATE OR REPLACE PACKAGE BODY pkg_Search
      2  AS
      3  PROCEDURE My_Procedure (
      4  arg_Cursor IN OUT CUSTOM_REF_CURSOR)
      5  IS
      6  BEGIN
      7  OPEN arg_Cursor FOR
      8  SELECT sysdate FROM DUAL;
      9  END;
     10  END;
     11  /
    
    Package body created.
    
  • Variable in which returns no rows

    Hello

    I'm sorry if this is a simple question but I must be missing something and I can not find the answer. I'm writing a very simple search, and when I get to the USER: P10_SEARCH (inside the SQL workshop pop up) it returns no rows, but when I change it to "where ut." USERNAME = 'USER' "without the double quote him returns the row for the USER username. I'm under APEX 3.2.0.00.27 in 10 Express. I looked at some examples of Oracle applications and I couldn't find my mistake, if someone could guide me in the right direction I'd appreciate it.


    Select ut. Username "username".
    ut. Username "username".
    ut. FIRST_NAME. ' ' || STH Last_name 'full name '.
    ut. DEPARTMENT "Department".
    c USER_TABLE
    where ut. USERNAME =: P10_SEARCH

    Hello
    If the USER name column is defined as a CHAR data type, then you will need to mount your binding variable (P10_SEARCH) being of the CHAR type.

    ....
    where a.USERNAME = cast( :P10_SEARCH as char(n)  )   --- where n is the same size as declared for USERNAME
    

    CITY

    Published by: city has on January 4, 2010 17:09

  • Explain plan - index range scan lines increase while access to the table by the row id

    I use Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64 bit Production. Please help me understand why the rows returned from the index range scan is 3 but access the table by row index 10155 id. Please refer to explain the plan ID 7 and 8.


    PLAN_TABLE_OUTPUT                                                                                   
    ----------------------------------------------------------------------------------------------------
                                                                                                        
    ---------------------------------------------------------------------------------------------       
    | Id  | Operation                      |  Name                      | Rows  | Bytes | Cost  |       
    ---------------------------------------------------------------------------------------------       
    |   0 | SELECT STATEMENT               |                            |  8308 |   446K|  4408 |       
    |   1 |  SORT ORDER BY                 |                            |  8308 |   446K|  4408 |       
    |*  2 |   HASH JOIN                    |                            |  8308 |   446K|  4316 |       
    |*  3 |    HASH JOIN                   |                            |  8189 |   255K|  2256 |       
    |*  4 |     INDEX FAST FULL SCAN       | TUNE_CHD_07                |  8071 | 72639 |   199 |       
    |*  5 |     TABLE ACCESS BY INDEX ROWID| CLM_HDR_CLM_LN_STATUS      | 10155 |   228K|  2055 |       
    |*  6 |      INDEX RANGE SCAN          | XIF3CLM_HDR_CLM_LN_STATUS  |     3 |       |   120 |       
    |*  7 |    TABLE ACCESS BY INDEX ROWID | CLM_HDR_CLM_LN_STATUS      | 10155 |   228K|  2055 |       
    |*  8 |     INDEX RANGE SCAN           | XIF3CLM_HDR_CLM_LN_STATUS  |     3 |       |   120 |       
    ---------------------------------------------------------------------------------------------       
                                                                                                        
    Predicate Information (identified by operation id):                                                 
    ---------------------------------------------------                                                 
                                                                                                        
       2 - access("CHCLS"."CLAIM_HEADER_SID"="CHCLS1"."CLAIM_HEADER_SID")                               
       3 - access("CHD"."CLAIM_HEADER_SID"="CHCLS"."CLAIM_HEADER_SID")                                  
       4 - filter("CHD"."CLM_TYPE_CID"=2)                                                               
       5 - filter("CHCLS"."CLAIM_LINE_SID" IS NULL AND "CHCLS"."TO_DATE" IS NULL)                       
       6 - access("CHCLS"."STATUS_TYPE_CID"=8 AND "CHCLS"."STATUS_CID"=71)                              
       7 - filter("CHCLS1"."CLAIM_LINE_SID" IS NULL AND "CHCLS1"."TO_DATE" IS NULL)                     
       8 - access("CHCLS1"."STATUS_TYPE_CID"=2 AND "CHCLS1"."STATUS_CID"=130)                           
                                                                                                        
    Note: cpu costing is off                                                                            
    Thanks a lot for all the help...
  • subquery returns no row in the main query, but hard returns the value of the master query

    Oracle 11g, Solaris SPARC 64-bit:

    This is the master query: its not to return all the lines

    Select count (*) in the sadmin.usr_mods where to_char (ts_id) in ((select to_char (rtrim (ltrim(TS_MODULES,','), ',')) in the sadmin.usr_rfc where TS_KINTANA_PACKAGE_NUMBER = '123' and ts_projectid = 3));

    COUNT (*)

    ----------

    0

    But wherever if I use subquery only returns he lines:

    SQL > select rtrim (ltrim(TS_MODULES,','), ',') from the sadmin.usr_rfc where TS_KINTANA_PACKAGE_NUMBER = '123' and ts_projectid = 3;

    RTRIM (LTRIM(TS_MODULES,','), ',')

    --------------------------------------------------------------------------------

    49,54

    If I use these values as hardcoded to a select master it will return 2 rows:

    SQL > select count (*) in the sadmin.usr_mods where to_char (ts_id) in ('49 ', ' 54');

    COUNT (*)

    ----------

    2

    TS_MODULES datatype is CLOB

    TS_ID datatype is set to number

    Help, please

    with

    usr_rfc as

    (select 3 ts_projectid, 123 ts_kintana_package_number, to_clob(',49,54,') ts_modules

    of the double

    ),

    usr_mods as

    (select ts_id 49 Union double all the)

    Select 50 in all double union

    Select double 54

    )

    Select count (*)

    of usr_mods

    where to_char (ts_id) in (select regexp_substr (to_char (rtrim (ltrim(TS_MODULES,','), ',')),'[^,] +', 1, level))

    of usr_rfc

    where TS_KINTANA_PACKAGE_NUMBER = '123'

    and ts_projectid = 3

    connect by level<= regexp_count(to_char(rtrim(ltrim(ts_modules,','),',')),',')="" +="">

    )

    COUNT (*)
    2

    Concerning

    Etbin

    Select count (*)

    of usr_mods

    where instr ((select ',' | to_char (rtrim (ltrim(TS_MODULES,','), ',')) |)) ','

    of usr_rfc

    where TS_KINTANA_PACKAGE_NUMBER = '123'

    and ts_projectid = 3

    ),

    ',' || TO_CHAR (TS_ID) | ','

    ) > 0

  • Remove the range of numbers from a text string

    I have a field that I need to remove a certain range of numbers, however, this area is VARCHAR2 and can contain letters.

    My current code is (in the Where clause): field.field_name not between '27000000' and '27999999'

    The problem is that it takes also documents that are not in this range, such as 27000.

    What code can I set in the where clause to fix this?

    OK, then change the class alnum class numbers:

    SELECT *.

    From your_table

    If NOT of REGEXP_LIKE (your_col, ' ^ 27 [[: digit:]] {6} $');

  • Explain the rows returned in a group plan of

    I have a (select statement) that returns 18 rows.

    wrap a select statement that is nested in a group by around it

    Select col_a, col_b of
    (select statement)
    Group of col_a, col_b

    Returns even 18 rows as expected

    explain that she and I see the 18 rows returned to Id 2 and the Group hash by, and then select lines 1.
                        
    ------------------------------------------------------------------------------------------------------------------------------------------------------                              
    | Id  | Operation                                   | Name                           | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     | Pstart| Pstop |                              
    ------------------------------------------------------------------------------------------------------------------------------------------------------                              
    |   0 | SELECT STATEMENT                            |                                |     1 |    95 |       | 90897  (75)| 00:00:02 |       |       |                              
    |   1 |  HASH GROUP BY                              |                                |     1 |    95 |       | 90897  (75)| 00:00:02 |       |       |                              
    |   2 |   VIEW                                      |                                |    18 |  1710 |       | 90896  (75)| 00:00:02 |       |       |        
    reason Im asking is I rewrote the SQL code in the internal instruction for adjustment purposes and I get even 18 rows as expected but now I have 2 lines referred to the hash group by.
    -----------------------------------------------------------------------------------------------------------------------------------------------------                               
    | Id  | Operation                                  | Name                           | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     | Pstart| Pstop |                               
    -----------------------------------------------------------------------------------------------------------------------------------------------------                               
    |   0 | SELECT STATEMENT                           |                                |     2 |   190 |       | 82657  (80)| 00:00:02 |       |       |                               
    |   1 |  HASH GROUP BY                             |                                |     2 |   190 |       | 82657  (80)| 00:00:02 |       |       |                               
    |   2 |   VIEW                                     |                                |    18 |  1710 |       | 82656  (80)| 00:00:02 |       |       |                               
    ..
    ..
    In regards to plans above that "lines" means for the hash group by.

    These are just estimates, not actually the rows returned.

    Sometimes, you can make this small change and a kind of funny the optimizer calculation may change.

    But that's just an estimate.

  • Interactive report that returns 0 rows on the initial screen of forcing

    How can I get the initial display of my interactive to have 0 rows (and quickly) reports on the initial display, so that the user can determine the lines they want without having to wait for the report view without much in the way of the filters?

    My reports many lines of 50-100 k with several joins of tables: so they are slow and the initial default result set is not useful for them, until they start of construction interactive filters themselves.

    I tried to add a default I / filter R which is never true, return 0 rows, but if I have good corrrectly, APEX will execute the sql 1, returning the default #of ranks backward, THEN that wraps like a subselect and applies to the i / R filters. So, I still have to wait for the report of 'run' before its filtered to 0 rows...

    I'm experimenting also with a flag of pxx_firsttime, intiall value, and according to my report SQL NVL(:Pxx_FIRSTTIME,'Y') = n and (rest of joins of tables)...
    the problem I have with this is, how can I get this option the value N as the user begins to use the interactive report filters, etc., which seem NOT to resubmit the page?

    Thank you

    Hello

    I tried to add a default I / filter R which is never true, return 0 rows, but if I have good corrrectly, APEX will execute the sql 1, returning back by default #of lines, THEN that wraps like a subselect and applies the > I / R filters. So, I still have to wait for the report of 'run' before its filtered to 0 rows...

    Yes, you are right.

    I assume that you already have using the paging Type as line from X to Y.

    the problem I have with this is, how can I get this option the value N as the user begins to use the interactive report filters, etc., which seem NOT to resubmit the page?

    Whenever the user do something with 'Actions', APEX IR will get updated. Thus, to create a dynamic Action that will be triggered before the refreshment of your IR, update the session state from P1_FIRSTTIME_FLAG to "n".

    Kind regards
    Hari

  • Not the rows returned by the spatial query wrapped in SELECT * FROM...

    Hello

    When you run a query with SDO_EQUAL sub, I get a very strange behavior. The SDO_EQUAL query on its own works very well, but if I wrap in SELECT * from there, I get no results. If I wrap SDO_ANYINTERACT in SELECT * from there, I get the expected result.

    It seems like the spatial index is used during the execution of the ordinary, but not when SDO_EQUAL request wrapped in SELECT * FROM. Weird. The spatial index is also not used when SDO_ANYINTERACT is wrapped in SELECT * FROM... so I don't know why that returns the correct answer.

    I get this problem on 11.2.0.2 on Red Hat Linux 64-bit and 11.2.0.1 on Windows XP 32-bit (i.e., all versions of 11g I've tried). The query works as expected on 10.2.0.5 on Windows Server 2003 64-bit.

    Any ideas?

    Confused in Dublin (John)

    Test case...
    SQL> 
    SQL> -- Create a table and insert the same geometry twice
    SQL> DROP TABLE sdo_equal_query_test;
    
    Table dropped.
    
    SQL> CREATE TABLE sdo_equal_query_test (
      2  id NUMBER,
      3  geometry SDO_GEOMETRY);
    
    Table created.
    
    SQL> 
    SQL> INSERT INTO sdo_equal_query_test VALUES (1,
      2  SDO_GEOMETRY(3003, 81989, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1),
      3  SDO_ORDINATE_ARRAY(1057.39, 1048.23, 4, 1057.53, 1046.04, 4, 1057.67, 1043.94, 4, 1061.17, 1044.60, 5, 1060.95, 1046.49, 5, 1060.81, 1047.78, 5, 1057.39, 1048.23, 4)));
    
    1 row created.
    
    SQL> 
    SQL> INSERT INTO sdo_equal_query_test VALUES (2,
      2  SDO_GEOMETRY(3003, 81989, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1),
      3  SDO_ORDINATE_ARRAY(1057.39, 1048.23, 4, 1057.53, 1046.04, 4, 1057.67, 1043.94, 4, 1061.17, 1044.60, 5, 1060.95, 1046.49, 5, 1060.81, 1047.78, 5, 1057.39, 1048.23, 4)));
    
    1 row created.
    
    SQL> 
    SQL> -- Setup metadata
    SQL> DELETE FROM user_sdo_geom_metadata WHERE table_name = 'SDO_EQUAL_QUERY_TEST';
    
    1 row deleted.
    
    SQL> INSERT INTO user_sdo_geom_metadata VALUES ('SDO_EQUAL_QUERY_TEST','GEOMETRY',
      2  SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', 0, 100000, .0001), SDO_DIM_ELEMENT('Y', 0, 100000, .0001), SDO_DIM_ELEMENT('Z', -100, 4000, .0001))
      3  ,81989);
    
    1 row created.
    
    SQL> 
    SQL> -- Create spatial index
    SQL> DROP INDEX sdo_equal_query_test_spind;
    DROP INDEX sdo_equal_query_test_spind
               *
    ERROR at line 1:
    ORA-01418: specified index does not exist
    
    
    SQL> CREATE INDEX sdo_equal_query_test_spind ON sdo_equal_query_test(geometry) INDEXTYPE IS MDSYS.SPATIAL_INDEX;
    
    Index created.
    
    SQL> 
    SQL> -- Ensure data is valid
    SQL> SELECT sdo_geom.validate_geometry_with_context(sdo_cs.make_2d(geometry), 0.0001) is_valid
      2  FROM sdo_equal_query_test;
    
    IS_VALID
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    TRUE
    TRUE
    
    2 rows selected.
    
    SQL> 
    SQL> -- Check query results using sdo_equal
    SQL> SELECT b.id
      2  FROM sdo_equal_query_test a, sdo_equal_query_test b
      3  WHERE a.id = 1
      4  AND b.id != a.id
      5  AND sdo_equal(a.geometry, b.geometry) = 'TRUE';
    
            ID
    ----------
             2
    
    1 row selected.
    
    SQL> 
    SQL> -- Check query results using sdo_equal wrapped in SELECT * FROM
    SQL> -- Results should be the same as above, but... no rows selected
    SQL> SELECT * FROM (
      2       SELECT b.id
      3       FROM sdo_equal_query_test a, sdo_equal_query_test b
      4       WHERE a.id = 1
      5       AND b.id != a.id
      6       AND sdo_equal(a.geometry, b.geometry) = 'TRUE'
      7  );
    
    no rows selected
    
    SQL> 
    SQL> -- So that didn't work.  Now try sdo_anyinteract... this works ok
    SQL> SELECT * FROM (
      2       SELECT b.id
      3       FROM sdo_equal_query_test a, sdo_equal_query_test b
      4       WHERE a.id = 1
      5       AND b.id != a.id
      6       AND sdo_anyinteract(a.geometry, b.geometry) = 'TRUE'
      7  );
    
            ID
    ----------
             2
    
    1 row selected.
    
    SQL> 
    SQL> -- Now try a scalar query
    SQL> SELECT * FROM (
      2       SELECT b.id
      3       FROM sdo_equal_query_test a, sdo_equal_query_test b
      4       WHERE a.id = 1
      5       AND b.id != a.id
      6  );
    
            ID
    ----------
             2
    
    1 row selected.
    
    SQL> spool off
    Here is the plan of the explain output for the query that works. Note that the spatial index is used.
    SQL> EXPLAIN PLAN FOR
      2  SELECT b.id
      3  FROM sdo_equal_query_test a, sdo_equal_query_test b
      4  WHERE a.id = 1
      5  AND b.id != a.id
      6  AND sdo_equal(a.geometry, b.geometry) = 'TRUE';
    
    Explained.
    
    SQL> @?/rdbms/admin/utlxpls.sql
    
    PLAN_TABLE_OUTPUT
    ------------------------------------------------------------------------------------------------------------
    Plan hash value: 3529470109
    
    ------------------------------------------------------------------------------------------------------------
    | Id  | Operation                     | Name                       | Rows  | Bytes | Cost (%CPU)| Time     |
    ------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT              |                            |     1 |  7684 |     3   (0)| 00:00:01 |
    |   1 |  RESULT CACHE                 | f5p63r46pbzty4sr45td1uv5g8 |       |       |            |       |
    |   2 |   NESTED LOOPS                |                            |     1 |  7684 |     3   (0)| 00:00:01 |
    |*  3 |    TABLE ACCESS FULL          | SDO_EQUAL_QUERY_TEST       |     1 |  3836 |     3   (0)| 00:00:01 |
    |*  4 |    TABLE ACCESS BY INDEX ROWID| SDO_EQUAL_QUERY_TEST       |     1 |  3848 |     3   (0)| 00:00:01 |
    |*  5 |     DOMAIN INDEX              | SDO_EQUAL_QUERY_TEST_SPIND |       |       |     0   (0)| 00:00:01 |
    ------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - filter("B"."ID"!=1)
       4 - filter("A"."ID"=1 AND "B"."ID"!="A"."ID")
       5 - access("MDSYS"."SDO_EQUAL"("A"."GEOMETRY","B"."GEOMETRY")='TRUE')
    ..... other stuff .....     
    Here is the plan of the explain output for the query is not working. Note that the spatial index is not used.
    SQL> EXPLAIN PLAN FOR
      2  SELECT * FROM (
      3     SELECT b.id
      4     FROM sdo_equal_query_test a, sdo_equal_query_test b
      5     WHERE a.id = 1
      6     AND b.id != a.id
      7     AND sdo_equal(a.geometry, b.geometry) = 'TRUE'
      8  );
    
    Explained.
    
    SQL> @?/rdbms/admin/utlxpls.sql
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------------------------
    Plan hash value: 1024466006
    
    --------------------------------------------------------------------------------------------------
    | Id  | Operation           | Name                       | Rows  | Bytes | Cost (%CPU)| Time     |
    --------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT    |                            |     1 |  7684 |     6   (0)| 00:00:01 |
    |   1 |  RESULT CACHE       | 2sd35wrcw3jr411bcg3sz161f6 |       |       |            |          |
    |   2 |   NESTED LOOPS      |                            |     1 |  7684 |     6   (0)| 00:00:01 |
    |*  3 |    TABLE ACCESS FULL| SDO_EQUAL_QUERY_TEST       |     1 |  3836 |     3   (0)| 00:00:01 |
    |*  4 |    TABLE ACCESS FULL| SDO_EQUAL_QUERY_TEST       |     1 |  3848 |     3   (0)| 00:00:01 |
    --------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - filter("B"."ID"!=1)
       4 - filter("A"."ID"=1 AND "B"."ID"!="A"."ID" AND
                  "MDSYS"."SDO_EQUAL"("A"."GEOMETRY","B"."GEOMETRY")='TRUE')
    ..... other stuff .....               

    Yes, this is the bug 9740355. You can get a 11.2.0.1 patch, or wait for 11.2.0.3.

  • Order in which the rows are returned from an external table

    Hello
    Anyone know if I can count on the rows returned in the order with a selection of Ext_table.
    For example:

    SELECT * FROM MY_EXT_TAB

    Where MY_EXT_TAB is a file read
    1
    2
    3

    The query will return to the top of the file down, that is to say 1-3.

    Thank you very much.

    Hello

    To get the number of the record since the beginning of the file, you can use the MASS_ADDITION_ID parameter in the external Table definition:

    http://download.Oracle.com/docs/CD/B19306_01/server.102/b14215/ldr_field_list.htm#sthref1264

    You define a column:

     RECNUM
    

    Then, in your application, you can use the operator order of this column.

    In this way, you ensure that you always comply with the registration order in the file.

    Hope this helps.
    Best regards
    Jean Valentine

  • User_Scheduler_Jobs query returns no row in the version 2.1.0.63

    Using the 2.1.0.63 version, "select * from user_scheduler_jobs;" returns no rows. It works fine in version 1.5.5.

    Published by: User65423 on February 8, 2010 09:24

    Refer to this topic, when the cause seems to be due to SQL Developer manages not null interval data types.

    bug? F9 gives no output dba_scheduler_jobs, version: 2.1.0.63.73

    As mentioned in this thread, you can use to_char on the columns of the interval as a workaround...

    SELECT source,
    destination,
    comments,
    flags,
    job_name,
    job_creator,
    client_id,
    global_uid,
    program_owner,
    program_name,
    job_type,
    job_action,
    number_of_arguments,
    schedule_owner,
    schedule_name,
    start_date,
    repeat_interval,
    end_date,
    job_class,
    enabled,
    auto_drop,
    restartable,
    state,
    job_priority,
    run_count,
    max_runs,
    failure_count,
    max_failures,
    retry_count,
    last_start_date,
    TO_CHAR(last_run_duration),
    next_run_date,
    TO_CHAR(schedule_limit),
    TO_CHAR(max_run_duration),
    logging_level,
    stop_on_window_close,
    instance_stickiness,
    system,
    job_weight,
    nls_env
    FROM user_scheduler_jobs a;
    

Maybe you are looking for