Intersect query

Hi,
Using Intersect query between two tables
1) select id from table A intersect select id from table B --> This will find the common records from two tables on the basis of common id
2) select id,event,time from table A intersect select id,event,time from table B --> What will be the result in case of multiple columns ?
In second query, does the query ignore the record if any one of the column value in table A do not match with the same column in table B ?
Edited by: user640001 on Jan 4, 2012 5:14 AM

Hi,
user640001 wrote:
... 2) select id,event,time from table A intersect select id,event,time from table B --> What will be the result in case of multiple columns ?
In second query, does the query ignore the record if any one of the column value in table A do not match with the same column in table B ?That's right, but don't take my word fior it. Try it and see.

Similar Messages

  • WKT polygon returns extra records on intersect query

    We have spatially enabled table with min/max lat/long with 1 degree cell data on which we perform queries coming from an application using well known text. We need to use WKT because we need to support user defined shapes of point, line, polygon, etc. (My test cases uses a rectangle). Our WKT data is accurate to 4 decimal places.
    //WKT version returns 100 records: (this is bad result)
    SELECT COUNT(*) from (select * from MAP_TABLE WHERE series='downunder') where sdo_relate(geometry,sdo_util.rectify_geometry(mdsys.sdo_geometry
    ('POLYGON((117.0627 -31.8451,117.0627 -27.0075,134.5875 -27.0075, 134.5875 -31.8451, 117.0627 -31.8451)))',8307),0.00005),'mask=anyinteract,querytype=window') = 'TRUE'
    // array version returns 90 records: (this is expected result)
    SELECT COUNT(*) from (select * from MAP_TABLE WHERE series='downunder') where sdo_relate(geometry,mdsys.sdo_geometry(2003,8307,null,mdsys.sdo_elem_info_array(1,1003,3),
    mdsys.sdo_ordinate_array(117.0627, -31.8451,134.5875,-27.0007)),'mask=anyinteract,querytype=window') = 'TRUE'
    The WKT seems to return extra records as if a .5 rounding error on the spatial query. We checked for tolerance; in USER_SDO_GEOM_METADATA, SDO_TOLERENCE for lon and lat in DIMINFO column are set to .0000005, and SRID of 8307, and the spatial index for the table has been recreated with .0000005 (just in case).
    Why is WKT not accurate?

    Hi Mike,
    Well, I'll be the first to line up and say that the WKT implementation has some issues. You already know them as you are doing that rectify_geometry step to account for some of them (incorrectly rotated rings which is what your example has).
    Noel is right that your example is not pushing along your case since an optimized rectangle is not the same as a regular rectangle, particularly in a geodetic cs. And that is one tiny tolerance in the rectify step! Is all your data at that tolerance? That's 0.0019685 inches! Wikipedia says the width of a human hair is 0.003937 inches so your tolerance is 1/3 of the width of a human hair. :)
    Anyhow, the second link Noel posted has the blurb we want: "When Spatial constructs the MBR internally for the query, lines along latitude lines are densified by adding points at one-degree intervals. This might affect results for objects within a few meters of the edge of the MBR (especially objects in the middle latitudes in both hemispheres)." So your optimized rectangle when its used internally by Oracle spatial looks like the results from this query:
    SELECT
    SDO_CS.TRANSFORM(
       MDSYS.SDO_GEOMETRY(2003,8307,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,3),MDSYS.SDO_ORDINATE_ARRAY(117.0627, -31.8451,134.5875,-27.0007)),
       8307
    FROM
    dualSo you can probably expect some differences in query results in comparison to the four point rectangle that your WKT input creates. And certainly will happen at the follicle scale!
    Could you post a different example that does not use an optimized rectangle where the SDO and WKT produce different outputs?
    If your data is stored as WKT, how did an optimized rectangle get into this story in the first place? If you need to store an optimized rectangle as WKT - well you can't do that. You could do the above transform trick on any optimized rectangles in your data and then put all the resulting points into your WKT. Then things should match on the output query side. But that would mean chucking out the whole concept of optimized triangles from your dataset.
    Cheers,
    Paul

  • Query Optimisation Problem

    Hi
    I have a problem regarding query optimisation, and in particularly one query. The query I have is for a view, and when I ran the cost on it, there were full table scans, and some costs were quite high:
    Select a.name, b.id, c.date
    from table a,
    table b,
    table c
    where a.id = b.id(+) and
    decode(a.version, null, a.num, a.version) = b.version(+) and
    a.id = c.id and
    b.type is null
    My question is whether this query can be made more efficient by removing the outer joins. I was thinking whether this could be carried out by some union or intersect query with an outer select. Is this possible, if so, what would be the best alternative query?
    Thanks

    Hi,
    Is b.type a NOT null column? Is the reason why you have b.type is null .. is to exclude the records that are present in both tableA and tableB, In that case try and see if this gives you the same result.
    select a.name,
           a.id,
           c.date
      from table1 a, table3 c
    where a.id = c.id
       and not exists
              (select 1
                 from table2 b
                where a.id = b.id
                  and nvl (a.version, a.num) = b.version)Make sure you have gathered statistics on the tables.
    And as sb92075 said above. Always mark a thread as answered once you get the answer. You need to help the forum as well rather than just taking help from the forum.
    G.

  • Query Performance Issue (help)

    I'm having issues w/ huge performance issues on the following. The sub intersect query lists duplicates in table1 and table2...and deletes those results from table2. But, the dups criteria is not looking at all fields, only those in the subquery....
    DELETE  FROM isw.accounts2     
           WHERE id_user||''||SYSTEM_ID||''||NM_DATABASE IN (
                  SELECT id_user||''||SYSTEM_ID||''||NM_DATABASE
                     FROM (
                           SELECT id_user, domain_name, system_name, user_description,
                                  user_dn, fl_system_user, dt_user_created,
                                  dt_user_modified, pw_changed, user_disabled,
                                  user_locked, pw_neverexpired, pw_expired,
                                  pw_locked, cd_geid, user_type, nm_database,
                                  cd_altname, fl_lob, cd_account_sid, system_id
                           FROM isw.accounts       -- accounts
                           WHERE SYSTEM_ID IN (SELECT SYSTEM_ID FROM SYSTEMS
                                               WHERE FL_LOB =  'type'  AND
                                               FL_SYSTEM_TYPE = 'Syst')
                           INTERSECT
                           SELECT id_user, domain_name, system_name, user_description,
                                  user_dn, fl_system_user, dt_user_created,
                                  dt_user_modified, pw_changed, user_disabled,
                                  user_locked, pw_neverexpired, pw_expired,
                                  pw_locked, cd_geid, user_type, nm_database,
                                  cd_altname, fl_lob, cd_account_sid, system_id
                           FROM isw.accounts2       --accounts_temp
                           WHERE SYSTEM_ID IN (SELECT SYSTEM_ID FROM SYSTEMS
                                               WHERE FL_LOB = 'type'
                                               AND FL_SYSTEM_TYPE =  'syst')
               )Edited by: Topher34 on Oct 24, 2008 12:00 PM
    Edited by: Topher34 on Oct 24, 2008 12:01 PM

    PLAN_TABLE_OUTPUT
    Plan hash value: 2030965500
    | Id  | Operation              | Name          | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT       |               |     1 |   623 |  2269   (7)| 00:00:28 |
    |*  1 |  FILTER                |               |       |       |            |          |
    |*  2 |   HASH JOIN SEMI       |               |     1 |   623 |   236   (2)| 00:00:03 |
    |   3 |    TABLE ACCESS FULL   | ACCOUNTS_BAX2 |     1 |   603 |   222   (1)| 00:00:03 |
    |*  4 |    TABLE ACCESS FULL   | SYSTEMS       |    15 |   300 |    14   (8)| 00:00:01 |
    |   5 |   VIEW                 |               |     1 |   117 |  2032   (7)| 00:00:25 |
    |   6 |    INTERSECTION        |               |       |       |            |          |
    |   7 |     SORT UNIQUE        |               |  2145 |   418K|            |          |
    |*  8 |      HASH JOIN         |               |  2145 |   418K|  1793   (8)| 00:00:22 |
    |*  9 |       TABLE ACCESS FULL| SYSTEMS       |    15 |   300 |    14   (8)| 00:00:01 |
    |* 10 |       TABLE ACCESS FULL| ACCOUNTS_BAX  |  2269 |   398K|  1779   (8)| 00:00:22 |
    |  11 |     SORT UNIQUE        |               |     1 |   588 |            |          |
    |* 12 |      HASH JOIN         |               |     1 |   588 |   236   (2)| 00:00:03 |
    |* 13 |       TABLE ACCESS FULL| ACCOUNTS_BAX2 |     1 |   568 |   222   (1)| 00:00:03 |
    |* 14 |       TABLE ACCESS FULL| SYSTEMS       |    15 |   300 |    14   (8)| 00:00:01 |
    Edited by: Topher34 on Oct 27, 2008 8:08 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Speed up intersection of two layers

    Hi,
    I'm trying to make an intersection of two layers work faster. First I create an empty table:
    create table shptmp as
    select sdo_geom.sdo_intersection(t1.geom, t2.geom, 0.005) intersect_geom,
    t1.id, t2.id from SHPTABLE1 t1, SHPTABLE t2
    where rownum < 1;
    Then I fill this table with intersection-polygons:
    insert into shptmp2
    select c.intersect_geom, id1, id2 FROM
    (SELECT /*+ ORDERED */ sdo_geom.sdo_intersection(t1.geom, t2.geom, 0.005) intersect_geom, t1.id id1, t2.id id2 from SHPTABLE1 t1, SHPTABLE2 t2
    where SDO_RELATE(t2.geom, t1.geom, 'mask=ANYINTERACT querytype=JOIN') = 'TRUE') c
    WHERE SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT(c.intersect_geom, 0.005) = 'TRUE';
    SHPTABLE1 and SHPTABLE2 both contain about 2000 polygons and multipolygons, and they have R-tree indexes. My resulting table shptmp contains about 9000 records when the query has finished. Anyway, it takes more than an hour to run the intersect-query. Is this a normal response-time for a spatial overlay of two layers? When I do something like a Union in ESRI ArcMap it only takes seconds or maybe minutes. Any ideas how to speed up this query? By the way my Oracle version is 9.2.0.1.0.
    Thanks,
    Anja

    Anja,
    An hour seems too long. Is there a spatial index defined on the temp table?
    Could you share your dataset so we can try to recreate the issue?
    I tried the following on a Linux server running Oracle 10.1.0.4
    SQL> select count(1) from map_airports_us ;
    COUNT(1)
    2346
    Elapsed: 00:00:00.01
    SQL> select count(1) from MAP_ADMIN_AREA4_US ;
    COUNT(1)
    28835
    Elapsed: 00:00:00.02
    SQL> select distinct t.geometry.sdo_gtype from map_airports_us t ;
    GEOMETRY.SDO_GTYPE
    2003
    2007
    SQL>
    1 select count(1) from
    2 (
    3 select /*+ ORDERED */ sdo_geom.sdo_intersection(a.geometry, b.geometry, 0.05) from
    4 table (sdo_join('MAP_AIRPORTS_US', 'GEOMETRY', 'MAP_ADMIN_AREA4_US',
    5 'GEOMETRY', 'mask=ANYINTERACT')) c, map_airports_us b, MAP_ADMIN_AREA4_US a
    6 where b.rowid = c.rowid1 and a.rowid = c.rowid2
    7* )
    SQL> /
    COUNT(1)
    2097
    Elapsed: 00:01:33.17
    SQL>
    1 select count(1) from
    2 (
    3 select /*+ ORDERED */ sdo_geom.sdo_intersection(a.geometry, b.geometry, 0.05) from
    4 map_airports_us b, MAP_ADMIN_AREA4_US a
    5 where sdo_relate(a.geometry, b.geometry, 'mask=anyinteract querytype=window')='TRUE'
    6* )
    SQL>
    SQL> /
    COUNT(1)
    2097
    Elapsed: 00:02:00.64
    SQL> SQL> create table tempint (id1 number, id2 number,
    2 geometry sdo_geometry);
    Table created.
    Elapsed: 00:00:01.01
    SQL>
    SQL> insert into tempint
    2 select /*+ ORDERED */ b.polygon_id, a.polygon_id,
    3 sdo_geom.sdo_intersection(a.geometry, b.geometry, 0.05) geometry
    4 from table (sdo_join('MAP_AIRPORTS_US', 'GEOMETRY', 'MAP_ADMIN_AREA4_US',
    5 'GEOMETRY', 'mask=ANYINTERACT')) c, map_airports_us b, MAP_ADMIN_AREA4_US a
    6 where b.rowid = c.rowid1 and a.rowid = c.rowid2 ;
    2097 rows created.
    Elapsed: 00:02:22.63
    SQL>
    So 2 minutes seems more like the right figure.
    Jayant

  • Performance problem with sdo_intersection. Your opinion?

    Hi,
    How would you accomplish the following task? (it’s not as complicated at it looks, please read on and feel challenged)
    I got two tables A and B both having a geom column and other attributes.
    Consider a row a1 in Table A having an attribute “Name” and a polygon in its geom-column, In table B I have a row b1, having an attribute “Zone” and also a polygon in its geom –column. The two polygons a1.geom and b1.geom partially intersect.
    What I need is a table with the following columns:
    IDLayer1, IDLayer2, Name, Zone, geom
    The rows must look something like this:
    Row 1 (the part of a1.geom also covered by b1.geom)
    a1, b1, myName, myZone, SDO_GEOMETRY….
    Row 2 (the part of a1.geom not covered by b1.geom):
    a1, null, myName, null, SDO_GEOMETRY…
    Row 3 ( the part of b1.geom not covered by a1)
    Null, b1, null, myZone, SDO_GEOMETRY)
    How I solved this problem:
    By calling a series of three SELECT statements I create Row1, 2 and 3 and fill in the result table.
    Row 1 is created as:
    INSERT INTO …
    SELECT /* ORDERED +/ A.id, B.id, A.Name, B.Zone, SDO_GEOM.SDO_INTERSECTION(A.geom, B.geom, 0.001)
    FROM A, B
    WHERE SDO_RELATE (a.geom, b.geom, 'mask=anyinteract') = 'TRUE'
    Row 2 is created as:
    SELECT /* ORDERED +/ A.id, null, A.Name, null, SDO_GEOM.SDO_DIFFERENCE(A.geom, B.geom, 0.001)
    FROM A, B
    WHERE SDO_RELATE (a.geom, b.geom, 'mask=anyinteract') = 'TRUE'
    Row 3 is created as:
    SELECT /* ORDERED +/ null, B.id, null, B.Zone, SDO_GEOM.SDO_DIFFERENCE(B.geom, A.geom, 0.001)
    FROM A, B
    WHERE SDO_RELATE (a.geom, b.geom, 'mask=anyinteract') = 'TRUE'
    Note: The queries above are simplified and don’t expose all details. The important point is, I do first an intersection, followed by two differences. I improved the performance, by reusing the result from the intersection query in the difference-queries. That is: I actually don’t do an SDO_RELATE in the where clauses of query 2 and 3 but instead I use the id’s from the Intersection query (If there is an intersection, there must also be a difference).
    A second simplification in the queries given above concerns the Difference operation when a geometry a1 from Layer A intersects with several geometries from Layer B (say b1 and b2). In this case I first call an Aggregate function:
    SDO_AGGR_UNION ( mdsys.sdoaggrtype(B.geom, 0.01))
    WHERE B.id someConditionResulting in b1 and b2
    The difference operation then looks something like this:
    SDO_GEOM.SDO_DIFFERENCE(A.geom, aggregatedGeometry, 0.001)
    Now the Problem:
    My Tables are quiet large containing thousands of geometries. Using the approach described above, it takes hours to compute the result. When doing the same task in a Desktop GIS (like Mapinfo), a single “intersect” operation is needed and the result is obtained within a few seconds.
    Question:
    How would you tackle the problem? May I improve the performance just by tuning the queries or is my approach wrong? What are your suggestions?
    Thank you!
    Marco

    You will get better performance if you make the three resulting geometries three
    columns in your new table.
    I am not sure why you need them as three rows.
    You can do:
    select sdo_geom.sdo_intersection(a.geom, b.geom, tolerance),
    sdo_geom.sdo_difference(a.geom, b.geom, tolerance),
    sdo_geom.sdo_difference(b.geom, a.geom, tolerance)
    where SDO_JOIN ...
    This way, you can do the whole thing with one select.
    siva

  • Querying multiple intersection tables against another table for row exists

    Hi all,
    Running on:
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
    With the Partitioning and OLAP options
    JServer Release 9.2.0.8.0 - Production
    I am setting up email subscription service for news service website. News articles are tagged with multiple audiences, topics, regions and departments. Legacy data model we're dealing with implements one intersection table (M:N) for each of audience, topic, region and department lookup table and main news article table.
    Email subscribers can pick any combination of the above options (audience, dept etc..) to customize the content of their email. Emails will be either daily or weekly digests of articles of interest, based on their chosen options.
    The subscriber options are captured in one table, each option type being its own column. I'm trying to write one query to basically extract all articles that match a given subscriber's chosen options.
    create table audiences(articleid number, audienceid number);
    create table topics(articleid number, topicid number);
    create table regions(articleid number, regionid number);
    create table depts(articleid number, deptid number);
    create table subscriber_options(emailid number,audienceid number,topicid number, regionid number, deptid number);
    insert into audiences(articleid,audienceid)
    SELECT
    ceil(dbms_random.value(1,10)),
    ceil(dbms_random.value(1,50))
    from all_objects where rownum < 100;
    insert into topics(articleid,topicid)
    select
    ceil(dbms_random.value(1,10)),
    ceil(dbms_random.value(1,50))
    from all_objects where rownum < 100;
    insert into regions(articleid,regionid)
    select
    ceil(dbms_random.value(1,10)),
    ceil(dbms_random.value(1,50))
    from all_objects where rownum < 100;
    insert into depts(articleid,deptid)
    select
    ceil(dbms_random.value(1,10)),
    ceil(dbms_random.value(1,50))
    from all_objects where rownum < 100;
    INSERT INTO subscriber_options (
       EMAILID, audienceid, topicid,
       regionid, deptid)
    select
    ceil(dbms_random.value(1,10)),
    ceil(dbms_random.value(1,50)),
    ceil(dbms_random.value(1,50)),
    ceil(dbms_random.value(1,50)),
    ceil(dbms_random.value(1,50))
    from all_objects where rownum < 100;
    commit;If a subscriber hasn't chosen any options, then no rows will exist in the subscriber_options table, which implies that they will receive all articles.
    I am struggling with this query.. can this be achieved using only 1 query or is this a case where some PL/SQL is required?
    All I really want to know is if a given subscriber option matches an option for a given article, using the following boolean logic (topic OR audience) AND dept AND region.
    Because I'm more concerned with row existence, I thought of using the "EXISTS" with subquery approach.
    Thanks for tips and advice.

    Well.. a little persistence, and I think I cracked this nut. ;-)
    WITH instant_subscribers AS
         (SELECT   email_subscriber_id, email_subscriber.subscriber_email,
                   email_subscriber.subscriber_first_name,
                   email_subscriber.subscriber_last_name,
                   email_subscriber.subscriber_identifier_code,
                   email_subscriber.languageid, COUNT (newscreatorid)
                                                                     dept_options,
                   COUNT (newscategoryid) topic_options,
                   COUNT (newscoveragespatialid) region_options,
                   COUNT (newsaudiencetypeid) audience_options
              FROM email_subscriber LEFT OUTER JOIN subscriber_option
                   USING (email_subscriber_id)
             WHERE email_subscriber.subscription_frquncy_type_id = 1
               AND email_subscriber.subscription_status_id = 2
               and email_subscriber_id=53169
          GROUP BY email_subscriber_id,
                   email_subscriber.subscriber_email,
                   email_subscriber.subscriber_first_name,
                   email_subscriber.subscriber_last_name,
                   email_subscriber.subscriber_identifier_code,
                   email_subscriber.languageid)
    SELECT subscr.*, d.*
      FROM instant_subscribers subscr,
           (SELECT ccnews.newsid, ccnews.title, ccnews.embargodate, ccnews.description,
                   ccnews.languageid
              FROM ccnews
             WHERE ccnews.embargodate >= TRUNC (SYSDATE - 7)
               AND ccnews.embargodate < TRUNC (SYSDATE)
               AND ccnews.newsstatusid = 2
               AND ccnews.isreadingroom = 'FALSE'
               )  d
    WHERE subscr.languageid = d.languageid and ( (subscr.audience_options=0 OR subscr.topic_options=0 OR EXISTS (
                        SELECT NULL
                              FROM subscriber_option INNER JOIN ccnews_audience_rel
                                   USING (newsaudiencetypeid, languageid)
                             WHERE subscriber_option.email_subscriber_id =
                                           subscr.email_subscriber_id
                               AND ccnews_audience_rel.newsid = d.newsid))
            OR ( EXISTS (
                     SELECT NULL
                              FROM subscriber_option INNER JOIN ccnews_category_rel
                                   USING (newscategoryid, languageid)
                             WHERE email_subscriber_id =
                                           subscr.email_subscriber_id
                               AND ccnews_category_rel.newsid = d.newsid))
       AND (subscr.dept_options = 0 OR EXISTS (
                    SELECT NULL
                          FROM subscriber_option INNER JOIN ccnews_creator_rel
                               USING (newscreatorid, languageid)
                         WHERE email_subscriber_id =
                                           subscr.email_subscriber_id
                           AND ccnews_creator_rel.newsid = d.newsid))
       AND (subscr.region_options = 0 OR EXISTS (
                        SELECT NULL
                          FROM subscriber_option INNER JOIN ccnews_coverage_spatial_rel
                               USING (newscoveragespatialid, languageid)
                         WHERE email_subscriber_id =
                                           subscr.email_subscriber_id
                           AND ccnews_coverage_spatial_rel.newsid = d.newsid)) order by d.embargodate DESCI basically outer join my subscriber (supertype) with my subscriber_options (subtype)... and count each option type groupe by subscriber, to determine if they have any options for given type (if count is 0, then they chose "all")
    From there, I use this count to "short-circuit" the predicates.. if count=0 OR exists subquery with inner join on chosen options matched to article.
    Explain plan reveals the following:
    Plan
    SELECT STATEMENT  CHOOSECost: 70  Bytes: 727  Cardinality: 1                                                    
         36 SORT ORDER BY  Cost: 70  Bytes: 727  Cardinality: 1                                               
              35 FILTER                                          
                   10 TABLE ACCESS BY INDEX ROWID NEWSROOM.CCNEWS Cost: 64  Bytes: 371  Cardinality: 1                                     
                        9 NESTED LOOPS  Cost: 68  Bytes: 727  Cardinality: 1                                
                             7 VIEW NEWSROOM_DEV02. Cost: 4  Bytes: 356  Cardinality: 1                           
                                  6 SORT GROUP BY  Cost: 4  Bytes: 121  Cardinality: 1                      
                                       5 FILTER                 
                                            4 NESTED LOOPS OUTER  Cost: 2  Bytes: 605  Cardinality: 5            
                                                 2 TABLE ACCESS BY INDEX ROWID NEWSROOM_DEV02.EMAIL_SUBSCRIBER Cost: 1  Bytes: 80  Cardinality: 1       
                                                      1 INDEX UNIQUE SCAN UNIQUE NEWSROOM_DEV02.EMLSUBSR_PK Cardinality: 1 
                                                 3 INDEX RANGE SCAN UNIQUE NEWSROOM_DEV02.SUBSCRIBER_OPTION_UQ_IDX Cost: 1  Bytes: 205  Cardinality: 5       
                             8 INDEX RANGE SCAN NON-UNIQUE NEWSROOM.CCNEWS_IN Cost: 1  Cardinality: 317                           
                   16 TABLE ACCESS BY INDEX ROWID NEWSROOM.CCNEWS_AUDIENCE_REL Cost: 5  Bytes: 12  Cardinality: 1                                     
                        15 NESTED LOOPS  Cost: 5  Bytes: 39  Cardinality: 1                                
                             12 TABLE ACCESS BY INDEX ROWID NEWSROOM_DEV02.SUBSCRIBER_OPTION Cost: 2  Bytes: 297  Cardinality: 11                           
                                  11 INDEX RANGE SCAN UNIQUE NEWSROOM_DEV02.SUBSCRIBER_OPTION_UQ_IDX Cost: 2  Cardinality: 4                      
                             14 BITMAP CONVERSION TO ROWIDS                           
                                  13 BITMAP INDEX SINGLE VALUE NEWSROOM.CCNEWS_AUDIENCE_REL_IN                     
                   22 TABLE ACCESS BY INDEX ROWID NEWSROOM.CCNEWS_CATEGORY_REL Cost: 5  Bytes: 12  Cardinality: 1                                     
                        21 NESTED LOOPS  Cost: 5  Bytes: 78  Cardinality: 2                                
                             18 TABLE ACCESS BY INDEX ROWID NEWSROOM_DEV02.SUBSCRIBER_OPTION Cost: 2  Bytes: 297  Cardinality: 11                           
                                  17 INDEX RANGE SCAN UNIQUE NEWSROOM_DEV02.SUBSCRIBER_OPTION_UQ_IDX Cost: 2  Cardinality: 4                      
                             20 BITMAP CONVERSION TO ROWIDS                           
                                  19 BITMAP INDEX SINGLE VALUE NEWSROOM.CCNEWS_CATEGORY_REL_IN                     
                   28 TABLE ACCESS BY INDEX ROWID NEWSROOM.CCNEWS_CREATOR_REL Cost: 5  Bytes: 14  Cardinality: 1                                     
                        27 NESTED LOOPS  Cost: 5  Bytes: 41  Cardinality: 1                                
                             24 TABLE ACCESS BY INDEX ROWID NEWSROOM_DEV02.SUBSCRIBER_OPTION Cost: 2  Bytes: 297  Cardinality: 11                           
                                  23 INDEX RANGE SCAN UNIQUE NEWSROOM_DEV02.SUBSCRIBER_OPTION_UQ_IDX Cost: 2  Cardinality: 4                      
                             26 BITMAP CONVERSION TO ROWIDS                           
                                  25 BITMAP INDEX SINGLE VALUE NEWSROOM.CCNEWS_CREATOR_REL_IN                     
                   34 TABLE ACCESS BY INDEX ROWID NEWSROOM.CCNEWS_COVERAGE_SPATIAL_REL Cost: 5  Bytes: 12  Cardinality: 1                                     
                        33 NESTED LOOPS  Cost: 5  Bytes: 39  Cardinality: 1                                
                             30 TABLE ACCESS BY INDEX ROWID NEWSROOM_DEV02.SUBSCRIBER_OPTION Cost: 2  Bytes: 297  Cardinality: 11                           
                                  29 INDEX RANGE SCAN UNIQUE NEWSROOM_DEV02.SUBSCRIBER_OPTION_UQ_IDX Cost: 2  Cardinality: 4                      
                             32 BITMAP CONVERSION TO ROWIDS                           
                                  31 BITMAP INDEX SINGLE VALUE NEWSROOM.CCNEWS_SPATIAL_REL_IN                     To me it looks pretty good... I'd be curious to know how it looks to a trained eye.. ;-)
    I do get my results back as expected...
    Edited by: pl_sequel on Sep 24, 2010 4:24 PM

  • How to query objects intersecting the coordinates

    Hi all,
    I am an Oracle Spatial Newbie. I made a search on the Google but could not find a simple answer for a simple question. I migrated my database from PostGIS to Oracle. I would like to learn the Oracle version of my PostGIS query:
    SELECT * from ykn WHERE ST_Intersects(poly, ST_MakeEnvelope(30.0, 37.792 , 30.1, 37.8,900914));
    All my records are converted to Oracle geometry type using a conversion tool. And also the R-tree index is added. I also would like to know how to query if the query has to be different to use the index.
    I'll be glad if you could help.
    Kindest Regards
    telmessos

    telmessos,
    By the way, what is the A here? I thought it is the table name and replaced A with YKN but got the same message."A" is an alias for the table YKN. You HAVE to use an alias whenever dereferencing the fields of any Oracle object. SDO_GEOMETRY
    is an Oracle object and sdo_srid is a field of that object so, to access its value you have to use an alias.
    Now, the original query - assuming the table sdo_geometry column is called POLY - didn't have an alias which would be confusing:
    select a.poly.sdo_srid from ykn where rownum < 2;
    -- Result
    ORA-00904 - "A"."POLY"."SRO_SRID": invalid identifier.What is missing here is the alias a after the table name YKN as in the following:
    select a.poly.sdo_srid from ykn a where rownum < 2;So, what we have is a rule
    Whenever accessing the fields / methods of an SDO_GEOMETRY we must:
    +1. Alias the table+
    +2. Use the alias when accessing column methods or fields eg <alias>.<column>.<field/method>+
    An example:
    select a.geom.sdo_gtype, a.geom.sdo_srid, a.geom.sdo_point.x, a.geom.sdo_point.y, a.geom.get_WKT() as wkt
      from projpoint2d a
    where rownum < 3;
    -- Results
    GEOM.SDO_GTYPE GEOM.SDO_SRID GEOM.SDO_POINT.X GEOM.SDO_POINT.Y WKT
    2001           NULL          363088.42        5405618          POINT (363088.42 5405618.0)
    2001           NULL          363202.85        5407375.46       POINT (363202.85 5407375.46)Note: All column above are fields of sdo_geometry except get_WKT() which is a method of sdo_geometry but still needs an alias to execute.
    HTH
    regards
    Simon

  • Spatial query w/ logical operators in a subquery on Linux using Oracle 1

    Hello...
    I'm being given XML that I need to parse and create SQL from it. Below my signature is the SQL that I generate (its a simple example) and can be more elaborate due to the logical operators (AND and OR) given in the XML.
    The problem that we're seeing is performance-based: when one of the logical operator queries is Spatial-based, like below. Running it in JDBC, the query never returns.
    The spatial query just by itself returns ~300 rows (takes approximately 0.2 seconds). The "PERCENTAGE" query by itself returns about ~40000 rows (takes approximately ~.8 seconds).
    If we run the query below with 2 non-spatial subqueries, the result returns and performance is very acceptable (~ 0.9 seconds)-- the result set is about 80000 rows.
    Thanks,
    Jim
    =========================
    SELECT
    COLUMN_WE_WANT , RESULTS
    FROM
    TABLE_A
    WHERE
    COLUMN_WE_WANT IN
    SELECT
    COLUMN_WE_WANT
    FROM
    TABLE_A
    WHERE
    SDO_OVERLAPBDYINTERSECT(TABLE_A.MY_SPATIAL_COLUMN,
    SDO_GEOMETRY(2003,
    4326,
    null,
    SDO_elem_info_array( 1 , 3 , 1 ),
    SDO_ORDINATE_ARRAY( lng_1,lat_1 , lng_2,lat_2 , lng_3,lat_3 , lng_4,lat_4 , lng_1,lat_1 )
    ) = 'TRUE'
    OR
    COLUMN_WE_WANT IN
    SELECT
    COLUMN_WE_WANT
    FROM
    TABLE_B
    WHERE
    SOME_PERCENTAGE_RATE_COLUMN < 90
    )

    Its difficult to comment without seeing the execution plan. You should trace this query to get a better idea of exactly what's happening.
    Depending on the complexity of the logical operators, I would look at doing this using set operations. So for an OR you might have...
    SELECT COLUMN_WE_WANT, RESULTS
    FROM TABLE_A
    WHERE COLUMN_WE_WANT IN (
         SELECT COLUMN_WE_WANT
         FROM TABLE_A
         WHERE SDO_OVERLAPBDYINTERSECT(TABLE_A.MY_SPATIAL_COLUMN,SDO_GEOMETRY(2003,4326,
         NULL, SDO_elem_info_array( 1 , 3 , 1 ),
         SDO_ORDINATE_ARRAY( lng_1,lat_1 , lng_2,lat_2 , lng_3,lat_3 , lng_4,lat_4 , lng_1,lat_1 ) )) = 'TRUE'
    UNION
         SELECT COLUMN_WE_WANT
         FROM TABLE_B
         WHERE SOME_PERCENTAGE_RATE_COLUMN < 90)For an AND, you would use INTERSECT.
    Edited by: Reggie to remove the extra INTERSECT

  • Structres and cells in Bex query designer?? urgent plz

    hi experts,
    could you please give me the useful info. regarding structres and cells with the examples.
    thanks in advance
    regards
    vadlamudi

    1. In the Query Designer, choose Cells (open) from the toolbar or use the menu option under View to reach the Cell Editor functions.
    2. You can now use four different functions.
    New Selection
    u2022 Select a cell in the Cells dialog box, and use the right mouse
    button to choose New Selection.
    u2022 Define the required selection.
    u2022 Enter a description for the selection and choose OK.
    New Formula
    u2022 Select a cell in the Cell dialog box, and use the right mouse button to choose New Formula.
    u2022 Define the required formula. Enter a description for the formula
    and choose OK.
    New Cell Reference
    Each cell that you define can be reused in formulas. If you want to reuse the value of the implicit generic cell definition that automatically occurs at the intersection of two structure parts of a query, select this cell in the Cell Definition dialog box, and choose New Cell Reference using the right mouse button. The description arising from the two structure parts
    automatically appears in the cell. You can now refer to this cell.
    Additional cells
    Click on the cell adjacent to the Help Cells and choose the required option if you need additional cells for auxiliary selections or formulas which are not already included in the query structure you have defined from the construction of rows and columns.
    Ashok

  • How to get Query Results based on Analysis Authorization Ranges????

    Hi Experts,
    I have gone through the lot of SDN Links, however not able to find the answer to my question.
    I have an Authorization Issue, “NO Authorization “
    Error : EYE 007 ( Insufficient Authorizations )
    <b>Here is the issue:</b>
    Need to see the complete query result when I gave the range in Analysis Authorization for Controlling Area 001-005. Controlling Area is auth relevant and right now a variable is inserted in the query for it. If I select Controlling Area 001, the result for Controlling Area 001 is displayed in query. If 002 then also displayed. If I do not enter anything, then I get the <b>Eye 007 error message</b>.
    I am not sure how do I display/authorize the entire result in the query for all the Controlling Areas, I have authorized user to see??
    <b>Its really urgent, please help..!</b>
    Here are the logs:
    Authorization Check Log
    Date and Execution Time (Local Server)
    Execution Date: 06.09.2007
    Execution Time: 14:48:41
    Executed Query: 0CCA_C11/GBCCA_MP01_Q0002_AP
    Executed by User ZBI_TEST_001
    Executed with Analysis Authorizations of Another User ZBI_TEST_001
      InfoProvider Check  
    Building the Buffer...
    ...Buffer Built
    Are there authorizations for accessing InfoProvider 0CCA_C11 with activity 03?
    Authorization exists for general access to InfoProvider 0CCA_C11 with activity 03 
      InfoProvider Check  
    Authorization exists for general access to InfoProvider 0CCA_C11 with activity 03 
      Relevant Characteristics for Detailed Authorization Check  
    (Characteristics with Full Authorization Are Not Listed!)
      List of Effective Authorization-Relevant Characteristics for InfoProvider 0CCA_C11:  
    0CO_AREA 
    0TCAACTVT 
      Relevant Characteristics for Detailed Authorization Check  
    (Characteristics with Full Authorization Are Not Listed!)
      List of Effective Authorization-Relevant Characteristics for InfoProvider :  
    List Is Empty:
      There Are No Characteristics That Have to Be Checked in Detail  
      Authorization Check  
      Detail Check for InfoProvider 0CCA_C11  
      Preprocessing:  
    Selection Checked for Consistency, Preprocessed and Supplemented As Needed
    Subselection (Technical SUBNR) 1
    Check Node Definitions and Value Authorizations...
    Node- and Value Authorizations Are OK
    End of Preprocessing
    Filling the Buffer...
    ...Buffer Filled
      Main Check:  
      Subselection (Technical SUBNR) 1  
    Supplementation of Selection for Aggregated Characteristics
      No Check for Aggregation Authorization Required  
    Following Set Is Checked  Comparison with Following Authorized Set  Result  Remaining Set 
    Characteristic  Contents 
    0CO_AREA
    0TCAACTVT
    SQL Format:
    CO_AREA = '0003'
    AND TCAACTVT = '03'
    Characteristic  Contents 
    0CO_AREA  I BT 0001 0005
    0TCAACTVT  I EQ 03
    I EQ 16
    Authorized   
      Subselection (SUBNR) Is Authorized  
      Authorization Check Complete  
      Authorization Check  
      Detail Check for InfoProvider 0CCA_C11  
      Preprocessing:  
    Selection Checked for Consistency, Preprocessed and Supplemented As Needed
    Subselection (Technical SUBNR) 1
    Check Node Definitions and Value Authorizations...
    Node- and Value Authorizations Are OK
    End of Preprocessing
    Filling the Buffer...
    ...Buffer Filled
      Main Check:  
      Subselection (Technical SUBNR) 1  
    Supplementation of Selection for Aggregated Characteristics
      No Check for Aggregation Authorization Required  
    Following Set Is Checked  Comparison with Following Authorized Set  Result  Remaining Set 
    Characteristic  Contents 
    0CO_AREA
    0TCAACTVT
    SQL Format:
    TCAACTVT = '03'
    Characteristic  Contents 
    0CO_AREA  I BT 0001 0005
    0TCAACTVT  I EQ 03
    I EQ 16
    Partially or Fully Authorized (Intersection)   Characteristic  Contents 
    0CO_AREA
    0TCAACTVT
    SQL Format:
    ( CO_AREA < '0001'
    OR CO_AREA > '0005' )
    AND TCAACTVT = '03'
    Value selection partially authorized. Check of remainder at end
    Following Set Is Checked  Comparison with Following Authorized Set  Result  Remaining Set 
    Characteristic  Contents 
    0CO_AREA
    0TCAACTVT
    SQL Format:
    ( CO_AREA < '0001'
    OR CO_AREA > '0005' )
    AND TCAACTVT = '03'
    Characteristic  Contents 
    0CO_AREA  I BT 0001 0005
    0TCAACTVT  I EQ 03
    I EQ 16
    Not Authorized   
    All Authorizations Tested
      Message EYE007: You do not have sufficient authorization  
      No Sufficient Authorization for This Subselection (SUBNR)  
    Following CHANMIDs Are Affected:
    184 ( 0CO_AREA )
      Authorization Check Complete  

    Hi,
        Have you defined the vaule for 0CO_AREA as BT 001-005 in you Authorization for 0CO_AREA.Also how have you defined your Authorization Variable on the query? Have you define as select options or interval? I thing you need to define it as interval or select options.
    Hope it helps,
    Cheers,
    Balaji

  • Pass intersection values when drilling through by clicking on a value in a matrix

    I have two SSRS reports. One is acting as a source report and the other as a target report.
    Both reports give information about "Customer Contact".
    My source report contains one matrix with the following attributes:
    Columns: Contact type (Email, Phone, Desk)
    Rows: Employee function (Administrative, Manager)
    Measure: Contact quantity
    The source report has two parameters on 'Contact type' and 'Employee function'
    My target report contains one matrix with the following attributes:
    Columns: Customer name
    Rows: Employee name
    Measure: Contact quantity
    The target report has two parameters on 'Contact type' and 'Employee function'
    I am using [Action] from the [Textbox property] of 'Contact Quantity' to go to my target report.
    What i want to achieve is the following:
    Lets say i select All for both parameters when running my source report.
    I get all the Contact types against all the Employee functions.
    Now the intersection between 'Email' and 'Manager' is 27.
    When i click on the value 27 in the matrix i want to go to my target report and pass trough Email and Manager so filtering can take place based on the intersection i clicked on in the source report.
    What it does now is just pass the full parameter value selected from the prompts in source report. I want to narrow it down.
    Any help? Thanks!

    Hello Qiuyun,
    Thank you very much for your reply.
    I have managed to get the drilltrough from source to target working correctly by passing the field value. I first got it to work on a small test data set and it works fine. However when i used this method on my production reports the performance became very
    bad. My first drilltrough took about 30 seconds instead of 2 seconds when i was passing the full parameter values. The next drilltrough gives back an out of memory error after quite some time (20 minutes +). 
    One important thing to mention is that these reports run on an SSAS cube. I made the following changes to the setup to get the pass field value method working.
    Initial setup: (Fast response)
    1. I start of by creating a new report.
    2. I select a the datasource (SSAS Cube) and i open the 'Query builder'.
    3. I then drag the attributes i need from the cube to the query.
    4. Afterwards i drag the attributes i want to use as parameters to the pane above the query and mark them as parameters. When finishing this step the parameters are automatically created in the design view (Report Data Pane) and within the data set of the
    report. When running the report the available values for the parameter are displayed automatically.
    5. Now i can run the report without having defined filters on the dataset. This setup performs very good but does not make it possible to pass trough field values.
    New setup: (Very slow response)
    1. I start of by creating a new report.
    2. I select a the datasource (SSAS Cube) and i open the 'Query builder'.
    3. I then drag the attributes i need from the cube to the query.
    4. I DON'T drag any attributes to the above pane (Dimension, Hierarchy, Operator, Filter Expression, Parameter) to be marked as parameters, i just finish after dragging to the query pane.
    5. Now i create my parameters manually in the design view (Report Data Pane).
    6. If i want to populate the parameters i do this by defining a separate dataset (query) per parameter to populate the drop down box. Otherwise i manually enter a string.
    7. I manually add the parameters to my dataset in the design view.
    8. Last i add filters which indicate what fields need to be filterd based on which parameter value.
    Any suggestions on how to get this working with acceptable performance?
    Thanks in advance for your help.
    (If you need screenshots to clarify the steps please let me know)
    Kind regards,
    Dennis

  • Can we see value of CKF in exception cell in query designer-please reply

    Hello all,
    I am defining a query in query designer in which i am using the exception cells, I am having two structures in this query. Now at the intersection of these two structure on one particular line I am trying to define the properties of that cell. I selected new selection and after that I added the calculated key figure that I had created. So should that cell show me the value of the calculated key figure (that is what I thought, that if I can put my CKF in that cell it will show me the value for that CKF). I am seeing different results.
    Is there any way you can actually show the value of calculated key figure in that particular cell.
    Thanks in advance,
    Raj

    Hi Raj,
    You can add Calculated key figure,RKF and even single key figures .The cells are independent of each other and that should not be an issue.
    Whatever the key figure is in the cell it should show that value.
    Just check again whether you have put any key figure into the selections of the structures
    There should be no key fgures into selctions.
    Hope it helps
    Thanks

  • Error in Query (EXCEPT)

    Dear Experts,
    I Have Error in query
    My Query Such as:
    Select TransNum from Oinm where transType=310000001
    Except
    Select Docnum from [dbo].[Opn_Stock] where U_ TransTypeStk=310000001
    Show Error: Browse mode is invalid for statements containing a UNION, INTERSECT and EXCEPT operator.
    Note: This query smoothly run in Sql 2005 but throw Error in SAP while execute in sap query generator.
    Regards,
    Sumeet Vaity

    The SBO generally inserts a for browse line at the end of the query. But not allways! E.g. probably your query would work if you refrase it in such a way:
    Select TransNum from Oinm where transType=310000001
    Except --union
    Select Docnum from dbo.Opn_Stock where U_ TransTypeStk=310000001
    That is it does not insert this line in case of a union, even in the comment part!

  • Executing a merge query for a collection

    Hello All,
    I am trying to use a merge query to find common and uncommon ids between a table and a list I pass to my pl-sql proc. I am not sure if I am doing the right thing, please guide me...
    Here is my code...
    Procedure process_content(i_eidlist IN ocs_eid_list_t, i_id IN number, o_new_email_list OUT ocs_eid_list_t) AS
    lv_last_processed_row_id number;
    lv_common_email_list ocs_eid_list_t;
    lv_internet_id varchar2;
    Begin
    lv_last_processed_row_id := 0;
    MERGE INTO table c
    USING TABLE(i_eidlist)a
    ON (c.eid in a)
    --WHEN MATCHED THEN UPDATE SET c.row_id = job_no_seq.NEXTVAL,c.copy_count=1 returning row_id bulk collect into lv_row_id_list;
    WHEN MATCHED THEN SELECT c.eid bulk collect into lv_common_email_list returning row_id bulk collect into lv_row_id_list
    WHEN NOT MATCHED THEN SELECT c.eid bulk collect into o_new_email_list;
    I am assuming that the merge query is going to iterate over the i_eidlist, and find me the common and uncommon elements. However, I get an error saying the sql block is ignored.
    Thanks
    Abhishek
    글 수정: A.J.

    I do not think it is possible in one pass. The best I could come up with:
    DECLARE
        COMMON_LIST NAME_LIST;
        UNCOMMON_LIST NAME_LIST;
        EMPLOYEE_LIST NAME_LIST;
        CHECK_LIST NAME_LIST := NAME_LIST('KING','QUEEN');
    BEGIN
        SELECT  ENAME
          BULK COLLECT INTO EMPLOYEE_LIST
          FROM  EMP;
        COMMON_LIST := EMPLOYEE_LIST MULTISET INTERSECT CHECK_LIST;
        UNCOMMON_LIST := EMPLOYEE_LIST MULTISET EXCEPT CHECK_LIST;
    DBMS_OUTPUT.PUT_LINE('-- COMMON_LIST --');
    FOR i IN 1..COMMON_LIST.COUNT LOOP
      DBMS_OUTPUT.PUT_LINE(COMMON_LIST(i));
    END LOOP;
    DBMS_OUTPUT.PUT_LINE('-- UNCOMMON_LIST --');
    FOR i IN 1..UNCOMMON_LIST.COUNT LOOP
      DBMS_OUTPUT.PUT_LINE(UNCOMMON_LIST(i));
    END LOOP;
    END;
    /Run results showing contents:
    SQL> DECLARE
      2      COMMON_LIST NAME_LIST;
      3      UNCOMMON_LIST NAME_LIST;
      4      EMPLOYEE_LIST NAME_LIST;
      5      CHECK_LIST NAME_LIST := NAME_LIST('KING','QUEEN');
      6  BEGIN
      7      SELECT  ENAME
      8        BULK COLLECT INTO EMPLOYEE_LIST
      9        FROM  EMP;
    10      COMMON_LIST := EMPLOYEE_LIST MULTISET INTERSECT CHECK_LIST;
    11      UNCOMMON_LIST := EMPLOYEE_LIST MULTISET EXCEPT CHECK_LIST;
    12  DBMS_OUTPUT.PUT_LINE('-- COMMON_LIST --');
    13  FOR i IN 1..COMMON_LIST.COUNT LOOP
    14    DBMS_OUTPUT.PUT_LINE(COMMON_LIST(i));
    15  END LOOP;
    16  DBMS_OUTPUT.PUT_LINE('-- UNCOMMON_LIST --');
    17  FOR i IN 1..UNCOMMON_LIST.COUNT LOOP
    18    DBMS_OUTPUT.PUT_LINE(UNCOMMON_LIST(i));
    19  END LOOP;
    20  END;
    21  /
    -- COMMON_LIST --
    KING
    -- UNCOMMON_LIST --
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    TURNER
    ADAMS
    JAMES
    FORD
    MILLER
    PL/SQL procedure successfully completed.
    SQL> SY.

Maybe you are looking for

  • Late 2013 retina macbook pro drops thunderbolt ethernet cyclically

    My new (late 2013) retina macbook pro drops the wired ethernet connection many times a day. Each time killing off all VPN and ssh sessions. This is using the apple thunderbolt to gigE adapter. This is the second thunderbolt adapter I've received from

  • Problem with WTK2.5.1 in Solaris 10

    Greetings, I've installed Wireless ToolKit 2.5.1 in Solaris 10 OS and after successful installation when I run the application from path /WTK2.5.1/bin/ktoolbar it gives me error like: ktoolbar : MMAPI_GM_SOUNDBANK=/WTK2.5.1/lib/soundman.dls is not a

  • Transfer files from old macbook pro to new macbook pro using mavericks

    I have called Apple support about 5 times about this and have been given 3 or 4 different response none of them work.  I do not have an ethernet cable. The computers are on same network. I have time capsule not yet set up.  Apple support told me to u

  • ID login comes up with error message

    I have changed my I'd login password three times and have logged in but after authinticating it comes up with error! I have compared my blackberry to friends of mine and it looks like my phone didn't download the app world properly when I registered!

  • Connection refuse

    Hi, I try to load test my web site using apache soap 2.2 for doing some web services. However, when I increase the number of threads in the load test. I got connection refused exception from OC4J and also find SOAPException : msg=Error opening socket